|
1 | 1 | /* |
2 | | - * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * |
4 | 4 | * This program is free software; you can redistribute it and/or modify it under |
5 | 5 | * the terms of the GNU General Public License, version 2.0, as published by the |
@@ -289,11 +289,12 @@ public static Socket performTlsHandshake(Socket rawSocket, SocketConnection sock |
289 | 289 |
|
290 | 290 | PropertySet pset = socketConnection.getPropertySet(); |
291 | 291 |
|
292 | | - SslMode sslMode = pset.<SslMode> getEnumProperty(PropertyKey.sslMode).getValue(); |
| 292 | + SslMode sslMode = pset.<SslMode>getEnumProperty(PropertyKey.sslMode).getValue(); |
293 | 293 | boolean verifyServerCert = sslMode == SslMode.VERIFY_CA || sslMode == SslMode.VERIFY_IDENTITY; |
294 | 294 |
|
295 | | - KeyStoreConf trustStore = !verifyServerCert ? new KeyStoreConf() : getTrustStoreConf(pset, PropertyKey.trustCertificateKeyStoreUrl, |
296 | | - PropertyKey.trustCertificateKeyStorePassword, PropertyKey.trustCertificateKeyStoreType, verifyServerCert && serverVersion == null); |
| 295 | + KeyStoreConf trustStore = !verifyServerCert ? new KeyStoreConf() |
| 296 | + : getTrustStoreConf(pset, PropertyKey.trustCertificateKeyStoreUrl, PropertyKey.trustCertificateKeyStorePassword, |
| 297 | + PropertyKey.trustCertificateKeyStoreType, verifyServerCert && serverVersion == null); |
297 | 298 |
|
298 | 299 | KeyStoreConf keyStore = getKeyStoreConf(pset, PropertyKey.clientCertificateKeyStoreUrl, PropertyKey.clientCertificateKeyStorePassword, |
299 | 300 | PropertyKey.clientCertificateKeyStoreType); |
@@ -573,7 +574,7 @@ public static SSLContext getSSLContext(String clientCertificateKeyStoreUrl, Stri |
573 | 574 | } |
574 | 575 |
|
575 | 576 | public static boolean isSSLEstablished(Socket socket) { |
576 | | - return SSLSocket.class.isAssignableFrom(socket.getClass()); |
| 577 | + return socket == null ? false : SSLSocket.class.isAssignableFrom(socket.getClass()); |
577 | 578 | } |
578 | 579 |
|
579 | 580 | public static RSAPublicKey decodeRSAPublicKey(String key) throws RSAException { |
@@ -616,11 +617,12 @@ public static AsynchronousSocketChannel startTlsOnAsynchronousChannel(Asynchrono |
616 | 617 |
|
617 | 618 | PropertySet propertySet = socketConnection.getPropertySet(); |
618 | 619 |
|
619 | | - SslMode sslMode = propertySet.<SslMode> getEnumProperty(PropertyKey.sslMode).getValue(); |
| 620 | + SslMode sslMode = propertySet.<SslMode>getEnumProperty(PropertyKey.sslMode).getValue(); |
620 | 621 |
|
621 | 622 | boolean verifyServerCert = sslMode == SslMode.VERIFY_CA || sslMode == SslMode.VERIFY_IDENTITY; |
622 | | - KeyStoreConf trustStore = !verifyServerCert ? new KeyStoreConf() : getTrustStoreConf(propertySet, PropertyKey.trustCertificateKeyStoreUrl, |
623 | | - PropertyKey.trustCertificateKeyStorePassword, PropertyKey.trustCertificateKeyStoreType, true); |
| 623 | + KeyStoreConf trustStore = !verifyServerCert ? new KeyStoreConf() |
| 624 | + : getTrustStoreConf(propertySet, PropertyKey.trustCertificateKeyStoreUrl, PropertyKey.trustCertificateKeyStorePassword, |
| 625 | + PropertyKey.trustCertificateKeyStoreType, true); |
624 | 626 |
|
625 | 627 | KeyStoreConf keyStore = getKeyStoreConf(propertySet, PropertyKey.clientCertificateKeyStoreUrl, PropertyKey.clientCertificateKeyStorePassword, |
626 | 628 | PropertyKey.clientCertificateKeyStoreType); |
|
0 commit comments