Fixed problem with the system SSL context initialization (seems to affect Windows only)
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1243661 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d969fe8774
commit
eac4ae43a7
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package org.apache.http.conn.ssl;
|
||||
|
||||
public class SSLInitializationException extends IllegalStateException {
|
||||
|
||||
private static final long serialVersionUID = -8243587425648536702L;
|
||||
|
||||
public SSLInitializationException(final String message, final Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
}
|
|
@ -296,12 +296,9 @@ public class SSLSocketFactory implements SchemeLayeredSocketFactory,
|
|||
tmfactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||
KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
|
||||
String trustStorePassword = System.getProperty("javax.net.ssl.trustStorePassword");
|
||||
if (trustStorePassword == null) {
|
||||
trustStorePassword = "changeit";
|
||||
}
|
||||
FileInputStream instream = new FileInputStream(trustStoreFile);
|
||||
try {
|
||||
trustStore.load(instream, trustStorePassword.toCharArray());
|
||||
trustStore.load(instream, trustStorePassword != null ? trustStorePassword.toCharArray() : null);
|
||||
} finally {
|
||||
instream.close();
|
||||
}
|
||||
|
@ -360,7 +357,7 @@ public class SSLSocketFactory implements SchemeLayeredSocketFactory,
|
|||
try {
|
||||
return createSSLContext(TLS, null, null, null, null, null);
|
||||
} catch (Exception ex) {
|
||||
throw new IllegalStateException("Failure initializing default SSL context", ex);
|
||||
throw new SSLInitializationException("Failure initializing default SSL context", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -368,7 +365,7 @@ public class SSLSocketFactory implements SchemeLayeredSocketFactory,
|
|||
try {
|
||||
return createSystemSSLContext(TLS, null);
|
||||
} catch (Exception ex) {
|
||||
throw new IllegalStateException("Failure initializing default system SSL context", ex);
|
||||
throw new SSLInitializationException("Failure initializing default system SSL context", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue