src/java.base/share/classes/sun/security/ssl/TransportContext.java
changeset 51141 2dd2d73c52f6
parent 50768 68fa3d4026ea
child 51407 910f7b56592f
equal deleted inserted replaced
51140:1edcf36fe15f 51141:2dd2d73c52f6
   391             throw (RuntimeException)closeReason;
   391             throw (RuntimeException)closeReason;
   392         }
   392         }
   393     }
   393     }
   394 
   394 
   395     void setUseClientMode(boolean useClientMode) {
   395     void setUseClientMode(boolean useClientMode) {
       
   396         // Once handshaking has begun, the mode can not be reset for the
       
   397         // life of this engine.
       
   398         if (handshakeContext != null || isNegotiated) {
       
   399             throw new IllegalArgumentException(
       
   400                     "Cannot change mode after SSL traffic has started");
       
   401         }
       
   402 
   396         /*
   403         /*
   397          * If we need to change the client mode and the enabled
   404          * If we need to change the client mode and the enabled
   398          * protocols and cipher suites haven't specifically been
   405          * protocols and cipher suites haven't specifically been
   399          * set by the user, change them to the corresponding
   406          * set by the user, change them to the corresponding
   400          * default ones.
   407          * default ones.
   401          */
   408          */
   402         if (sslConfig.isClientMode != useClientMode) {
   409         if (sslConfig.isClientMode != useClientMode) {
   403             // Once handshaking has begun, the mode can not be reset for the
       
   404             // life of this engine.
       
   405             if (handshakeContext != null || isNegotiated) {
       
   406                 throw new IllegalArgumentException(
       
   407                     "Cannot change mode after SSL traffic has started");
       
   408             }
       
   409 
       
   410             if (sslContext.isDefaultProtocolVesions(
   410             if (sslContext.isDefaultProtocolVesions(
   411                     sslConfig.enabledProtocols)) {
   411                     sslConfig.enabledProtocols)) {
   412                 sslConfig.enabledProtocols =
   412                 sslConfig.enabledProtocols =
   413                         sslContext.getDefaultProtocolVersions(!useClientMode);
   413                         sslContext.getDefaultProtocolVersions(!useClientMode);
   414             }
   414             }