src/java.base/share/classes/sun/security/ssl/ServerHandshakeContext.java
author wetmore
Fri, 11 May 2018 15:53:12 -0700
branchJDK-8145252-TLS13-branch
changeset 56542 56aaa6cb3693
parent 48225 src/java.base/share/classes/sun/security/ssl/ServerHandshaker.java@718669e6b375
child 56715 b152d06ed6a9
permissions -rw-r--r--
Initial TLSv1.3 Implementation
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
56542
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
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
56542
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 48225
diff changeset
    28
import java.io.IOException;
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 48225
diff changeset
    29
import java.security.AlgorithmConstraints;
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
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;
20539
cbff16f695c6 6956398: make ephemeral DH key match the length of the certificate key
xuelei
parents: 19823
diff changeset
    32
import sun.security.action.GetPropertyAction;
56542
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 48225
diff changeset
    33
import sun.security.action.GetLongAction;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
56542
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 48225
diff changeset
    35
class ServerHandshakeContext extends HandshakeContext {
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 48225
diff changeset
    36
    // To prevent the TLS renegotiation issues, by setting system property
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 48225
diff changeset
    37
    // "jdk.tls.rejectClientInitiatedRenegotiation" to true, applications in
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 48225
diff changeset
    38
    // server side can disable all client initiated SSL renegotiations
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 48225
diff changeset
    39
    // regardless of the support of TLS protocols.
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 48225
diff changeset
    40
    //
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 48225
diff changeset
    41
    // By default, allow client initiated renegotiations.
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 48225
diff changeset
    42
    static final boolean rejectClientInitiatedRenego =
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 48225
diff changeset
    43
            Utilities.getBooleanProperty(
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 48225
diff changeset
    44
                "jdk.tls.rejectClientInitiatedRenegotiation", false);
20539
cbff16f695c6 6956398: make ephemeral DH key match the length of the certificate key
xuelei
parents: 19823
diff changeset
    45
31689
1201792aa3a3 8043201: Deprecate RC4 in SunJSSE provider
asmotrak
parents: 31538
diff changeset
    46
    // legacy algorithm constraints
56542
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 48225
diff changeset
    47
    static final AlgorithmConstraints legacyAlgorithmConstraints =
31689
1201792aa3a3 8043201: Deprecate RC4 in SunJSSE provider
asmotrak
parents: 31538
diff changeset
    48
            new LegacyAlgorithmConstraints(
1201792aa3a3 8043201: Deprecate RC4 in SunJSSE provider
asmotrak
parents: 31538
diff changeset
    49
                    LegacyAlgorithmConstraints.PROPERTY_TLS_LEGACY_ALGS,
1201792aa3a3 8043201: Deprecate RC4 in SunJSSE provider
asmotrak
parents: 31538
diff changeset
    50
                    new SSLAlgorithmDecomposer());
1201792aa3a3 8043201: Deprecate RC4 in SunJSSE provider
asmotrak
parents: 31538
diff changeset
    51
56542
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 48225
diff changeset
    52
    // temporary authentication information
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 48225
diff changeset
    53
    SSLPossession interimAuthn;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
56542
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 48225
diff changeset
    55
    StatusResponseManager.StaplingParameters stapleParams;
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 48225
diff changeset
    56
    CertificateMessage.CertificateEntry currentCertEntry;
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 48225
diff changeset
    57
    private static final long DEFAULT_STATUS_RESP_DELAY = 5000L;
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 48225
diff changeset
    58
    final long statusRespTimeout;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
56542
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 48225
diff changeset
    61
    ServerHandshakeContext(SSLContextImpl sslContext,
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 48225
diff changeset
    62
            TransportContext conContext) throws IOException {
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 48225
diff changeset
    63
        super(sslContext, conContext);
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 48225
diff changeset
    64
        long respTimeOut = AccessController.doPrivileged(
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 48225
diff changeset
    65
                    new GetLongAction("jdk.tls.stapling.responseTimeout",
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 48225
diff changeset
    66
                        DEFAULT_STATUS_RESP_DELAY));
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 48225
diff changeset
    67
        statusRespTimeout = respTimeOut >= 0 ? respTimeOut :
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 48225
diff changeset
    68
                DEFAULT_STATUS_RESP_DELAY;
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 48225
diff changeset
    69
        handshakeConsumers.put(
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 48225
diff changeset
    70
                SSLHandshake.CLIENT_HELLO.id, SSLHandshake.CLIENT_HELLO);
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 48225
diff changeset
    71
    }
14194
971f46db533d 7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents: 12874
diff changeset
    72
56542
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 48225
diff changeset
    73
    @Override
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 48225
diff changeset
    74
    void kickstart() throws IOException {
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 48225
diff changeset
    75
        if (!conContext.isNegotiated || kickstartMessageDelivered) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
56542
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 48225
diff changeset
    79
        SSLHandshake.kickstart(this);
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 48225
diff changeset
    80
        kickstartMessageDelivered = true;
36442
ce858cc19004 8132942: ServerHandshaker should not throw SSLHandshakeException when CertificateStatus constructor is called with invalid arguments
jnimeh
parents: 36132
diff changeset
    81
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
}
56542
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 48225
diff changeset
    83