Reputation: 1195
I have this code:
String auth = username + ":" + password;
URL url = new URL(hostname + path);
TrustManager[] trustAllCerts = new TrustManager[] { new SSLTrustManager() };
HostnameVerifier hostnameVerifier = new SSLHostnameVerifier();
SSLContext sc = SSLContext.getInstance("SSL");
sc.init(null, trustAllCerts, new java.security.SecureRandom());
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
HttpsURLConnection.setDefaultHostnameVerifier(hostnameVerifier);
HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
conn.setRequestProperty("Authorization", "Basic " + auth);
conn.connect();
The problem I encounter is this: with IBM JDK 6, everything works fine, with IBM JDB 7 it fails with error:
IBMJSSEProvider2 Build-Level: -20110720
keyStore is: C:\Program Files\IBM\Java70\jre\lib\security\cacerts
keyStore type is: jks
keyStore provider is:
init keystore
SSLContextImpl: Using X509ExtendedKeyManager com.ibm.jsse2.tc
SSLContextImpl: Using X509TrustManager com.ibm.cmsng.iem.SSLTrustManager
trigger seeding of SecureRandom
done seeding SecureRandom
Installed Providers =
IBMJSSE2
IBMJCE
IBMJGSSProvider
IBMCertPath
IBMSASL
IBMXMLCRYPTO
IBMXMLEnc
IBMSPNEGO
SUN
JsseJCE: Using KeyAgreement ECDH from provider IBMJCE version 1.7
JsseJCE: Using signature SHA1withECDSA from provider IBMJCE version 1.7
JsseJCE: Using signature NONEwithECDSA from provider IBMJCE version 1.7
JsseJCE: Using KeyFactory EC from provider IBMJCE version 1.7
JsseJCE: Using KeyPairGenerator EC from provider TBD via init
JsseJce: EC is available
JsseJCE: Using cipher AES/CBC/NoPadding from provider TBD via init
JsseJCE: Using SecureRandom from provider IBMJCE version 1.7
java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
What could be the problem ? I am using the same host:port combination, no changes. What is changed in SSL support in IBM JDK from version 6 to 7? I also tried with java 8 from Oracle, and again no success.
Upvotes: 0
Views: 653
Reputation: 123320
java.net.ConnectException: Connection refused: connect at java.net.DualStackPlainSocketImpl.connect0(Native Method)
The problem has nothing to do with TLS, but the TCP connect already fails. It might be that you are using the Java 6 and Java 7 programs on different systems and that the second one has no connection to the target host. It might also that IPv4 connection works but not the IPv6 one but the name server returned both IPv4 and IPv6 and Java 6 is using the IPv4 while Java 7 the IPv6 address (and fails).
Upvotes: 1