diff --git a/httpclient/src/main/java/org/apache/http/conn/ssl/SSLInitializationException.java b/httpclient/src/main/java/org/apache/http/conn/ssl/SSLInitializationException.java new file mode 100644 index 000000000..defd7e1cd --- /dev/null +++ b/httpclient/src/main/java/org/apache/http/conn/ssl/SSLInitializationException.java @@ -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 + * . + * + */ +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); + } + +} diff --git a/httpclient/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java b/httpclient/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java index d736c8fd2..f2592a4cc 100644 --- a/httpclient/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java +++ b/httpclient/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java @@ -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); } }