use of javax.net.ssl.SSLEngine in project java-chassis by ServiceComb.
the class SSLManagerTest method testCreateSSLEngine.
@Test
public void testCreateSSLEngine() {
SSLOption option = SSLOption.build(DIR + "/server.ssl.properties");
SSLCustom custom = new SSLCustom() {
@Override
public String getFullPath(String filename) {
return DIR + "/ssl/" + filename;
}
@Override
public char[] decode(char[] encrypted) {
return encrypted;
}
};
SSLEngine aSSLEngine = SSLManager.createSSLEngine(option, custom);
Assert.assertEquals(false, aSSLEngine.getUseClientMode());
Assert.assertNotNull(aSSLEngine);
}
use of javax.net.ssl.SSLEngine in project java-chassis by ServiceComb.
the class SSLManager method createSSLEngine.
public static SSLEngine createSSLEngine(SSLOption option, SSLCustom custom) {
SSLContext context = createSSLContext(option, custom);
SSLEngine engine = context.createSSLEngine();
engine.setEnabledProtocols(option.getProtocols().split(","));
String[] supported = engine.getSupportedCipherSuites();
String[] eanbled = option.getCiphers().split(",");
engine.setEnabledCipherSuites(getEnabledCiphers(supported, eanbled));
engine.setNeedClientAuth(option.isAuthPeer());
return engine;
}
use of javax.net.ssl.SSLEngine in project java-chassis by ServiceComb.
the class SSLManager method createSSLEngine.
public static SSLEngine createSSLEngine(SSLOption option, SSLCustom custom, String peerHost, int peerPort) {
SSLContext context = createSSLContext(option, custom);
SSLEngine engine = context.createSSLEngine(peerHost, peerPort);
engine.setEnabledProtocols(option.getProtocols().split(","));
String[] supported = engine.getSupportedCipherSuites();
String[] eanbled = option.getCiphers().split(",");
engine.setEnabledCipherSuites(getEnabledCiphers(supported, eanbled));
engine.setNeedClientAuth(option.isAuthPeer());
return engine;
}
use of javax.net.ssl.SSLEngine in project java-chassis by ServiceComb.
the class TrustManagerExtTest method testCheckClientTrusted.
@Test
public void testCheckClientTrusted(@Mocked CertificateUtil certificateUtil) {
MyX509Certificate myX509Certificate1 = new MyX509Certificate();
MyX509Certificate myX509Certificate2 = new MyX509Certificate();
MyX509Certificate[] MyX509CertificateArray = new MyX509Certificate[2];
MyX509CertificateArray[0] = myX509Certificate1;
MyX509CertificateArray[1] = myX509Certificate2;
new Expectations() {
{
CertificateUtil.findOwner((X509Certificate[]) any);
result = any;
CertificateUtil.getCN((X509Certificate) any);
result = "10.67.147.115";
}
};
MyX509ExtendedTrustManager myX509ExtendedTrustManager = new MyX509ExtendedTrustManager();
TrustManagerExt trustManagerExt = new TrustManagerExt(myX509ExtendedTrustManager, option, custom);
Socket socket = null;
SSLEngine sslengine = null;
boolean validAssert = true;
try {
trustManagerExt.checkClientTrusted(MyX509CertificateArray, "pks", socket);
trustManagerExt.checkClientTrusted(MyX509CertificateArray, "pks", sslengine);
trustManagerExt.checkServerTrusted(MyX509CertificateArray, "pks", socket);
trustManagerExt.checkServerTrusted(MyX509CertificateArray, "pks", sslengine);
} catch (Exception e) {
validAssert = false;
}
Assert.assertTrue(validAssert);
}
use of javax.net.ssl.SSLEngine in project jdk8u_jdk by JetBrains.
the class AcceptLargeFragments method main.
public static void main(String[] args) throws Exception {
SSLContext context = SSLContext.getDefault();
// set the property before initialization SSLEngine.
System.setProperty("jsse.SSLEngine.acceptLargeFragments", "true");
SSLEngine cliEngine = context.createSSLEngine();
cliEngine.setUseClientMode(true);
SSLEngine srvEngine = context.createSSLEngine();
srvEngine.setUseClientMode(false);
SSLSession cliSession = cliEngine.getSession();
SSLSession srvSession = srvEngine.getSession();
// check packet buffer sizes.
if (cliSession.getPacketBufferSize() < 33049 || srvSession.getPacketBufferSize() < 33049) {
throw new Exception("Don't accept large SSL/TLS fragments");
}
// check application data buffer sizes.
if (cliSession.getApplicationBufferSize() < 32768 || srvSession.getApplicationBufferSize() < 32768) {
throw new Exception("Don't accept large SSL/TLS application data ");
}
}
Aggregations