src/java.base/share/classes/sun/security/ssl/ServerHandshakeContext.java
author xuelei
Mon, 25 Jun 2018 13:41:39 -0700
changeset 50768 68fa3d4026ea
parent 48225 src/java.base/share/classes/sun/security/ssl/ServerHandshaker.java@718669e6b375
permissions -rw-r--r--
8196584: TLS 1.3 Implementation Reviewed-by: ascarpino, coffeys, dfuchs, jjiang, jnimeh, mullan, rhalade, ssahoo, valeriep, weijun, wetmore, xuelei Contributed-by: Adam Petcher <adam.petcher@oracle.com>, Amanda Jiang <amanda.jiang@oracle.com>, Anthony Scarpino <anthony.scarpino@oracle.com>, Bradford Wetmore <bradford.wetmore@oracle.com>, Jamil Nimeh <jamil.j.nimeh@oracle.com>, John Jiang <sha.jiang@oracle.com>, Rajan Halade <rajan.halade@oracle.com>, Sibabrata Sahoo <sibabrata.sahoo@oracle.com>, Valerie Peng <valerie.peng@oracle.com>, Weijun Wang <weijun.wang@oracle.com>, Xuelei Fan <xuelei.fan@oracle.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
50768
68fa3d4026ea 8196584: TLS 1.3 Implementation
xuelei
parents: 48225
diff changeset
     2
 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 5182
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 5182
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 5182
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 5182
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 5182
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package sun.security.ssl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
50768
68fa3d4026ea 8196584: TLS 1.3 Implementation
xuelei
parents: 48225
diff changeset
    28
import java.io.IOException;
68fa3d4026ea 8196584: TLS 1.3 Implementation
xuelei
parents: 48225
diff changeset
    29
import java.security.AlgorithmConstraints;
68fa3d4026ea 8196584: TLS 1.3 Implementation
xuelei
parents: 48225
diff changeset
    30
import java.security.AccessController;
31689
1201792aa3a3 8043201: Deprecate RC4 in SunJSSE provider
asmotrak
parents: 31538
diff changeset
    31
import sun.security.util.LegacyAlgorithmConstraints;
50768
68fa3d4026ea 8196584: TLS 1.3 Implementation
xuelei
parents: 48225
diff changeset
    32
import sun.security.action.GetLongAction;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
50768
68fa3d4026ea 8196584: TLS 1.3 Implementation
xuelei
parents: 48225
diff changeset
    34
class ServerHandshakeContext extends HandshakeContext {
68fa3d4026ea 8196584: TLS 1.3 Implementation
xuelei
parents: 48225
diff changeset
    35
    // To prevent the TLS renegotiation issues, by setting system property
68fa3d4026ea 8196584: TLS 1.3 Implementation
xuelei
parents: 48225
diff changeset
    36
    // "jdk.tls.rejectClientInitiatedRenegotiation" to true, applications in
68fa3d4026ea 8196584: TLS 1.3 Implementation
xuelei
parents: 48225
diff changeset
    37
    // server side can disable all client initiated SSL renegotiation
68fa3d4026ea 8196584: TLS 1.3 Implementation
xuelei
parents: 48225
diff changeset
    38
    // regardless of the support of TLS protocols.
68fa3d4026ea 8196584: TLS 1.3 Implementation
xuelei
parents: 48225
diff changeset
    39
    //
68fa3d4026ea 8196584: TLS 1.3 Implementation
xuelei
parents: 48225
diff changeset
    40
    // By default, allow client initiated renegotiation.
68fa3d4026ea 8196584: TLS 1.3 Implementation
xuelei
parents: 48225
diff changeset
    41
    static final boolean rejectClientInitiatedRenego =
68fa3d4026ea 8196584: TLS 1.3 Implementation
xuelei
parents: 48225
diff changeset
    42
            Utilities.getBooleanProperty(
68fa3d4026ea 8196584: TLS 1.3 Implementation
xuelei
parents: 48225
diff changeset
    43
                "jdk.tls.rejectClientInitiatedRenegotiation", false);
20539
cbff16f695c6 6956398: make ephemeral DH key match the length of the certificate key
xuelei
parents: 19823
diff changeset
    44
31689
1201792aa3a3 8043201: Deprecate RC4 in SunJSSE provider
asmotrak
parents: 31538
diff changeset
    45
    // legacy algorithm constraints
50768
68fa3d4026ea 8196584: TLS 1.3 Implementation
xuelei
parents: 48225
diff changeset
    46
    static final AlgorithmConstraints legacyAlgorithmConstraints =
31689
1201792aa3a3 8043201: Deprecate RC4 in SunJSSE provider
asmotrak
parents: 31538
diff changeset
    47
            new LegacyAlgorithmConstraints(
1201792aa3a3 8043201: Deprecate RC4 in SunJSSE provider
asmotrak
parents: 31538
diff changeset
    48
                    LegacyAlgorithmConstraints.PROPERTY_TLS_LEGACY_ALGS,
1201792aa3a3 8043201: Deprecate RC4 in SunJSSE provider
asmotrak
parents: 31538
diff changeset
    49
                    new SSLAlgorithmDecomposer());
1201792aa3a3 8043201: Deprecate RC4 in SunJSSE provider
asmotrak
parents: 31538
diff changeset
    50
50768
68fa3d4026ea 8196584: TLS 1.3 Implementation
xuelei
parents: 48225
diff changeset
    51
    // temporary authentication information
68fa3d4026ea 8196584: TLS 1.3 Implementation
xuelei
parents: 48225
diff changeset
    52
    SSLPossession interimAuthn;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
50768
68fa3d4026ea 8196584: TLS 1.3 Implementation
xuelei
parents: 48225
diff changeset
    54
    StatusResponseManager.StaplingParameters stapleParams;
68fa3d4026ea 8196584: TLS 1.3 Implementation
xuelei
parents: 48225
diff changeset
    55
    CertificateMessage.CertificateEntry currentCertEntry;
68fa3d4026ea 8196584: TLS 1.3 Implementation
xuelei
parents: 48225
diff changeset
    56
    private static final long DEFAULT_STATUS_RESP_DELAY = 5000L;
68fa3d4026ea 8196584: TLS 1.3 Implementation
xuelei
parents: 48225
diff changeset
    57
    final long statusRespTimeout;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
50768
68fa3d4026ea 8196584: TLS 1.3 Implementation
xuelei
parents: 48225
diff changeset
    60
    ServerHandshakeContext(SSLContextImpl sslContext,
68fa3d4026ea 8196584: TLS 1.3 Implementation
xuelei
parents: 48225
diff changeset
    61
            TransportContext conContext) throws IOException {
68fa3d4026ea 8196584: TLS 1.3 Implementation
xuelei
parents: 48225
diff changeset
    62
        super(sslContext, conContext);
68fa3d4026ea 8196584: TLS 1.3 Implementation
xuelei
parents: 48225
diff changeset
    63
        long respTimeOut = AccessController.doPrivileged(
68fa3d4026ea 8196584: TLS 1.3 Implementation
xuelei
parents: 48225
diff changeset
    64
                    new GetLongAction("jdk.tls.stapling.responseTimeout",
68fa3d4026ea 8196584: TLS 1.3 Implementation
xuelei
parents: 48225
diff changeset
    65
                        DEFAULT_STATUS_RESP_DELAY));
68fa3d4026ea 8196584: TLS 1.3 Implementation
xuelei
parents: 48225
diff changeset
    66
        statusRespTimeout = respTimeOut >= 0 ? respTimeOut :
68fa3d4026ea 8196584: TLS 1.3 Implementation
xuelei
parents: 48225
diff changeset
    67
                DEFAULT_STATUS_RESP_DELAY;
68fa3d4026ea 8196584: TLS 1.3 Implementation
xuelei
parents: 48225
diff changeset
    68
        handshakeConsumers.put(
68fa3d4026ea 8196584: TLS 1.3 Implementation
xuelei
parents: 48225
diff changeset
    69
                SSLHandshake.CLIENT_HELLO.id, SSLHandshake.CLIENT_HELLO);
68fa3d4026ea 8196584: TLS 1.3 Implementation
xuelei
parents: 48225
diff changeset
    70
    }
14194
971f46db533d 7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents: 12874
diff changeset
    71
50768
68fa3d4026ea 8196584: TLS 1.3 Implementation
xuelei
parents: 48225
diff changeset
    72
    @Override
68fa3d4026ea 8196584: TLS 1.3 Implementation
xuelei
parents: 48225
diff changeset
    73
    void kickstart() throws IOException {
68fa3d4026ea 8196584: TLS 1.3 Implementation
xuelei
parents: 48225
diff changeset
    74
        if (!conContext.isNegotiated || kickstartMessageDelivered) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
50768
68fa3d4026ea 8196584: TLS 1.3 Implementation
xuelei
parents: 48225
diff changeset
    78
        SSLHandshake.kickstart(this);
68fa3d4026ea 8196584: TLS 1.3 Implementation
xuelei
parents: 48225
diff changeset
    79
        kickstartMessageDelivered = true;
36442
ce858cc19004 8132942: ServerHandshaker should not throw SSLHandshakeException when CertificateStatus constructor is called with invalid arguments
jnimeh
parents: 36132
diff changeset
    80
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
}
50768
68fa3d4026ea 8196584: TLS 1.3 Implementation
xuelei
parents: 48225
diff changeset
    82