src/java.base/share/classes/sun/security/ssl/SSLContextImpl.java
changeset 53018 8bf9268df0e2
parent 51771 1f805481d8de
child 53734 cb1642ccc732
equal deleted inserted replaced
53017:e10a1f7aaa13 53018:8bf9268df0e2
   434         if (SSLLogger.isOn && SSLLogger.isOn("ssl,sslctx")) {
   434         if (SSLLogger.isOn && SSLLogger.isOn("ssl,sslctx")) {
   435             SSLLogger.fine(
   435             SSLLogger.fine(
   436                     "System property " + propertyName + " is set to '" +
   436                     "System property " + propertyName + " is set to '" +
   437                     property + "'");
   437                     property + "'");
   438         }
   438         }
   439         if (property != null && property.length() != 0) {
   439         if (property != null && !property.isEmpty()) {
   440             // remove double quote marks from beginning/end of the property
   440             // remove double quote marks from beginning/end of the property
   441             if (property.length() > 1 && property.charAt(0) == '"' &&
   441             if (property.length() > 1 && property.charAt(0) == '"' &&
   442                     property.charAt(property.length() - 1) == '"') {
   442                     property.charAt(property.length() - 1) == '"') {
   443                 property = property.substring(1, property.length() - 1);
   443                 property = property.substring(1, property.length() - 1);
   444             }
   444             }
   445         }
   445         }
   446 
   446 
   447         if (property != null && property.length() != 0) {
   447         if (property != null && !property.isEmpty()) {
   448             String[] cipherSuiteNames = property.split(",");
   448             String[] cipherSuiteNames = property.split(",");
   449             Collection<CipherSuite> cipherSuites =
   449             Collection<CipherSuite> cipherSuites =
   450                         new ArrayList<>(cipherSuiteNames.length);
   450                         new ArrayList<>(cipherSuiteNames.length);
   451             for (int i = 0; i < cipherSuiteNames.length; i++) {
   451             for (int i = 0; i < cipherSuiteNames.length; i++) {
   452                 cipherSuiteNames[i] = cipherSuiteNames[i].trim();
   452                 cipherSuiteNames[i] = cipherSuiteNames[i].trim();
   843             String property = GetPropertyAction.privilegedGetProperty(propname);
   843             String property = GetPropertyAction.privilegedGetProperty(propname);
   844             if (property == null) {
   844             if (property == null) {
   845                 return;
   845                 return;
   846             }
   846             }
   847 
   847 
   848             if (property.length() != 0) {
   848             if (!property.isEmpty()) {
   849                 // remove double quote marks from beginning/end of the property
   849                 // remove double quote marks from beginning/end of the property
   850                 if (property.length() > 1 && property.charAt(0) == '"' &&
   850                 if (property.length() > 1 && property.charAt(0) == '"' &&
   851                         property.charAt(property.length() - 1) == '"') {
   851                         property.charAt(property.length() - 1) == '"') {
   852                     property = property.substring(1, property.length() - 1);
   852                     property = property.substring(1, property.length() - 1);
   853                 }
   853                 }
   854             }
   854             }
   855 
   855 
   856             if (property.length() != 0) {
   856             if (!property.isEmpty()) {
   857                 String[] protocols = property.split(",");
   857                 String[] protocols = property.split(",");
   858                 for (int i = 0; i < protocols.length; i++) {
   858                 for (int i = 0; i < protocols.length; i++) {
   859                     protocols[i] = protocols[i].trim();
   859                     protocols[i] = protocols[i].trim();
   860                     // Is it a supported protocol name?
   860                     // Is it a supported protocol name?
   861                     ProtocolVersion pv =
   861                     ProtocolVersion pv =
  1107 
  1107 
  1108             FileInputStream fs = null;
  1108             FileInputStream fs = null;
  1109             KeyStore ks = null;
  1109             KeyStore ks = null;
  1110             char[] passwd = null;
  1110             char[] passwd = null;
  1111             try {
  1111             try {
  1112                 if (defaultKeyStore.length() != 0 &&
  1112                 if (!defaultKeyStore.isEmpty() &&
  1113                         !NONE.equals(defaultKeyStore)) {
  1113                         !NONE.equals(defaultKeyStore)) {
  1114                     fs = AccessController.doPrivileged(
  1114                     fs = AccessController.doPrivileged(
  1115                             new PrivilegedExceptionAction<FileInputStream>() {
  1115                             new PrivilegedExceptionAction<FileInputStream>() {
  1116                         @Override
  1116                         @Override
  1117                         public FileInputStream run() throws Exception {
  1117                         public FileInputStream run() throws Exception {
  1119                         }
  1119                         }
  1120                     });
  1120                     });
  1121                 }
  1121                 }
  1122 
  1122 
  1123                 String defaultKeyStorePassword = props.get("keyStorePasswd");
  1123                 String defaultKeyStorePassword = props.get("keyStorePasswd");
  1124                 if (defaultKeyStorePassword.length() != 0) {
  1124                 if (!defaultKeyStorePassword.isEmpty()) {
  1125                     passwd = defaultKeyStorePassword.toCharArray();
  1125                     passwd = defaultKeyStorePassword.toCharArray();
  1126                 }
  1126                 }
  1127 
  1127 
  1128                 /**
  1128                 /**
  1129                  * Try to initialize key store.
  1129                  * Try to initialize key store.
  1130                  */
  1130                  */
  1131                 if ((defaultKeyStoreType.length()) != 0) {
  1131                 if ((defaultKeyStoreType.length()) != 0) {
  1132                     if (SSLLogger.isOn && SSLLogger.isOn("ssl,defaultctx")) {
  1132                     if (SSLLogger.isOn && SSLLogger.isOn("ssl,defaultctx")) {
  1133                         SSLLogger.finest("init keystore");
  1133                         SSLLogger.finest("init keystore");
  1134                     }
  1134                     }
  1135                     if (defaultKeyStoreProvider.length() == 0) {
  1135                     if (defaultKeyStoreProvider.isEmpty()) {
  1136                         ks = KeyStore.getInstance(defaultKeyStoreType);
  1136                         ks = KeyStore.getInstance(defaultKeyStoreType);
  1137                     } else {
  1137                     } else {
  1138                         ks = KeyStore.getInstance(defaultKeyStoreType,
  1138                         ks = KeyStore.getInstance(defaultKeyStoreType,
  1139                                             defaultKeyStoreProvider);
  1139                                             defaultKeyStoreProvider);
  1140                     }
  1140                     }
  1559             }
  1559             }
  1560 
  1560 
  1561             // check endpoint identity
  1561             // check endpoint identity
  1562             String identityAlg = sslSocket.getSSLParameters().
  1562             String identityAlg = sslSocket.getSSLParameters().
  1563                                         getEndpointIdentificationAlgorithm();
  1563                                         getEndpointIdentificationAlgorithm();
  1564             if (identityAlg != null && identityAlg.length() != 0) {
  1564             if (identityAlg != null && !identityAlg.isEmpty()) {
  1565                 String hostname = session.getPeerHost();
  1565                 String hostname = session.getPeerHost();
  1566                 X509TrustManagerImpl.checkIdentity(
  1566                 X509TrustManagerImpl.checkIdentity(
  1567                                     hostname, chain[0], identityAlg);
  1567                                     hostname, chain[0], identityAlg);
  1568             }
  1568             }
  1569 
  1569 
  1599             }
  1599             }
  1600 
  1600 
  1601             // check endpoint identity
  1601             // check endpoint identity
  1602             String identityAlg = engine.getSSLParameters().
  1602             String identityAlg = engine.getSSLParameters().
  1603                                         getEndpointIdentificationAlgorithm();
  1603                                         getEndpointIdentificationAlgorithm();
  1604             if (identityAlg != null && identityAlg.length() != 0) {
  1604             if (identityAlg != null && !identityAlg.isEmpty()) {
  1605                 String hostname = session.getPeerHost();
  1605                 String hostname = session.getPeerHost();
  1606                 X509TrustManagerImpl.checkIdentity(
  1606                 X509TrustManagerImpl.checkIdentity(
  1607                                     hostname, chain[0], identityAlg);
  1607                                     hostname, chain[0], identityAlg);
  1608             }
  1608             }
  1609 
  1609