private SSLSocketFactory getInnerFactory() throws IOException {
if (innerFactory == null)
{
String algorithm = "TLSv1";
SSLKeyException xx;
KeyManager[] km = null;
TrustManager[] tm = null;
try {
SSLContext sslCtx = SSLContext.getInstance(algorithm);
if (trustManager != null)
{
tm = new TrustManager[] { trustManager };
}
if (keyManager != null)
{
km = new KeyManager[] { keyManager };
}
sslCtx.init(km, tm, new java.security.SecureRandom() );
innerFactory = sslCtx.getSocketFactory();
}
catch(GeneralSecurityException x) {
xx = new SSLKeyException("Failed to create SSLContext for " +
algorithm);
xx.initCause(x);
throw xx;
}
}
return innerFactory;
}