use of javax.net.ssl.SSLKeyException in project robovm by robovm.
the class SSLKeyExceptionTest method test_Constructor01.
/**
* Test for <code>SSLKeyException(String)</code> constructor Assertion:
* constructs SSLKeyException with detail message msg. Parameter
* <code>msg</code> is not null.
*/
public void test_Constructor01() {
SSLKeyException skE;
for (int i = 0; i < msgs.length; i++) {
skE = new SSLKeyException(msgs[i]);
assertEquals("getMessage() must return: ".concat(msgs[i]), skE.getMessage(), msgs[i]);
assertNull("getCause() must return null", skE.getCause());
}
}
use of javax.net.ssl.SSLKeyException in project robovm by robovm.
the class SSLKeyExceptionTest method test_Constructor02.
/**
* Test for <code>SSLPeerUnverifiedException(String)</code> constructor Assertion:
* constructs SSLPeerUnverifiedException with detail message msg. Parameter
* <code>msg</code> is null.
*/
public void test_Constructor02() {
String msg = null;
SSLKeyException skE = new SSLKeyException(msg);
assertNull("getMessage() must return null.", skE.getMessage());
assertNull("getCause() must return null", skE.getCause());
}
use of javax.net.ssl.SSLKeyException in project fabric8 by fabric8io.
the class KubernetesHelper method isServiceSsl.
public static boolean isServiceSsl(String host, int port, boolean trustAllCerts) {
try {
LOG.info("Checking if a service is SSL on " + host + ":" + port);
SSLSocketFactory sslsocketfactory;
if (trustAllCerts) {
sslsocketfactory = TrustEverythingSSLTrustManager.getTrustingSSLSocketFactory();
} else {
sslsocketfactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
}
Socket socket = sslsocketfactory.createSocket();
// Connect, with an explicit timeout value
socket.connect(new InetSocketAddress(host, port), 1 * 1000);
try {
InputStream in = socket.getInputStream();
OutputStream out = socket.getOutputStream();
// Write a test byte to get a reaction :)
out.write(1);
while (in.available() > 0) {
System.out.print(in.read());
}
return true;
} finally {
LOG.info("Checked if a service is SSL on " + host + ":" + port);
socket.close();
}
} catch (SSLHandshakeException e) {
LOG.error("SSL handshake failed - this probably means that you need to trust the kubernetes root SSL certificate or set the environment variable " + Utils.convertSystemPropertyNameToEnvVar(io.fabric8.kubernetes.client.Config.KUBERNETES_TRUST_CERT_SYSTEM_PROPERTY), e);
} catch (SSLProtocolException e) {
LOG.error("SSL protocol error", e);
} catch (SSLKeyException e) {
LOG.error("Bad SSL key", e);
} catch (SSLPeerUnverifiedException e) {
LOG.error("Could not verify server", e);
} catch (SSLException e) {
LOG.debug("Address does not appear to be SSL-enabled - falling back to http", e);
} catch (IOException e) {
LOG.debug("Failed to validate service", e);
}
return false;
}
Aggregations