LOG.info("using secure socket"); try (X509Util x509Util = new ClientX509Util()) { SSLContext sslContext = x509Util.getDefaultSSLContext(); SSLSocketFactory socketFactory = sslContext.getSocketFactory(); SSLSocket sslSock = (SSLSocket) socketFactory.createSocket();
@Test(timeout = 5000) public void testCreateSSLContextWithoutKeyStoreLocation() throws Exception { System.clearProperty(x509Util.getSslKeystoreLocationProperty()); x509Util.getDefaultSSLContext(); }
@Test(timeout = 5000) public void testCRLDisabled() throws Exception { x509Util.getDefaultSSLContext(); Assert.assertFalse(Boolean.valueOf(System.getProperty("com.sun.net.ssl.checkRevocation"))); Assert.assertFalse(Boolean.valueOf(System.getProperty("com.sun.security.enableCRLDP"))); Assert.assertFalse(Boolean.valueOf(Security.getProperty("ocsp.enable"))); }
@Test(timeout = 5000) public void testOCSPEnabled() throws Exception { System.setProperty(x509Util.getSslOcspEnabledProperty(), "true"); x509Util.getDefaultSSLContext(); Assert.assertTrue(Boolean.valueOf(System.getProperty("com.sun.net.ssl.checkRevocation"))); Assert.assertTrue(Boolean.valueOf(System.getProperty("com.sun.security.enableCRLDP"))); Assert.assertTrue(Boolean.valueOf(Security.getProperty("ocsp.enable"))); }
@Test(timeout = 5000) public void testCRLEnabled() throws Exception { System.setProperty(x509Util.getSslCrlEnabledProperty(), "true"); x509Util.getDefaultSSLContext(); Assert.assertTrue(Boolean.valueOf(System.getProperty("com.sun.net.ssl.checkRevocation"))); Assert.assertTrue(Boolean.valueOf(System.getProperty("com.sun.security.enableCRLDP"))); Assert.assertFalse(Boolean.valueOf(Security.getProperty("ocsp.enable"))); }
@Test(timeout = 5000) public void testCreateSSLContextWithCustomProtocol() throws Exception { final String protocol = "TLSv1.1"; System.setProperty(x509Util.getSslProtocolProperty(), protocol); SSLContext sslContext = x509Util.getDefaultSSLContext(); Assert.assertEquals(protocol, sslContext.getProtocol()); }
@Test(timeout = 5000) public void testCreateSSLContextWithoutCustomProtocol() throws Exception { SSLContext sslContext = x509Util.getDefaultSSLContext(); Assert.assertEquals(X509Util.DEFAULT_PROTOCOL, sslContext.getProtocol()); }
@Test(timeout = 5000, expected = X509Exception.SSLContextException.class) public void testCreateSSLContextWithoutKeyStorePassword() throws Exception { if (!x509TestContext.isKeyStoreEncrypted()) { throw new X509Exception.SSLContextException(""); } System.clearProperty(x509Util.getSslKeystorePasswdProperty()); x509Util.getDefaultSSLContext(); }