22 lines
736 B
Text
22 lines
736 B
Text
|
|
// Create the context. Specify the SunJSSE provider to avoid
|
|
// picking up third-party providers. Try the TLS 1.2 provider
|
|
// first, then fall back to TLS 1.0.
|
|
SSLContext ctx;
|
|
try {
|
|
ctx = SSLContext.getInstance("TLSv1.2", "SunJSSE");
|
|
} catch (NoSuchAlgorithmException e) {
|
|
try {
|
|
ctx = SSLContext.getInstance("TLSv1", "SunJSSE");
|
|
} catch (NoSuchAlgorithmException e1) {
|
|
// The TLS 1.0 provider should always be available.
|
|
throw new AssertionError(e1);
|
|
} catch (NoSuchProviderException e1) {
|
|
throw new AssertionError(e1);
|
|
}
|
|
} catch (NoSuchProviderException e) {
|
|
// The SunJSSE provider should always be available.
|
|
throw new AssertionError(e);
|
|
}
|
|
ctx.init(null, null, null);
|
|
|