@Test public void testNoKeyCert() { testInvalidKeyStore(null, "Key/certificate is mandatory for SSL", null); }
@Test public void testPKCS12InvalidPassword() { testInvalidKeyStore(Cert.SERVER_PKCS12.get().setPassword("wrongpassword"), Arrays.asList( "failed to decrypt safe contents entry: javax.crypto.BadPaddingException: Given final block not properly padded", "keystore password was incorrect"), null); }
@Test public void testKeyCertInvalidPem() throws IOException { String[] contents = { "", "-----BEGIN PRIVATE KEY-----", "-----BEGIN RSA PRIVATE KEY-----", "-----BEGIN PRIVATE KEY-----\n-----END PRIVATE KEY-----", "-----BEGIN RSA PRIVATE KEY-----\n-----END RSA PRIVATE KEY-----", "-----BEGIN PRIVATE KEY-----\n*\n-----END PRIVATE KEY-----", "-----BEGIN RSA PRIVATE KEY-----\n*\n-----END RSA PRIVATE KEY-----" }; String[] messages = { "Missing -----BEGIN PRIVATE KEY----- or -----BEGIN RSA PRIVATE KEY----- delimiter", "Missing -----END PRIVATE KEY----- delimiter", "Missing -----END RSA PRIVATE KEY----- delimiter", "Empty pem file", "Empty pem file", "Input byte[] should at least have 2 bytes for base64 bytes", "Input byte[] should at least have 2 bytes for base64 bytes" }; for (int i = 0;i < contents.length;i++) { Path file = testFolder.newFile("vertx" + UUID.randomUUID().toString() + ".pem").toPath(); Files.write(file, Collections.singleton(contents[i])); String expectedMessage = messages[i]; testInvalidKeyStore(Cert.SERVER_PEM.get().setKeyPath(file.toString()), expectedMessage, null); } }
@Test public void testPKCS12InvalidPath() { testInvalidKeyStore(Cert.SERVER_PKCS12.get().setPath("/invalid.p12"), "java.nio.file.NoSuchFileException: ", "invalid.p12"); }
@Test public void testJKSMissingPassword() { testInvalidKeyStore(Cert.SERVER_JKS.get().setPassword(null), "Password must not be null", null); }
@Test public void testKeyCertMissingKeyPath() { testInvalidKeyStore(Cert.SERVER_PEM.get().setKeyPath(null), "Missing private key", null); }
@Test public void testKeyCertInvalidKeyPath() { testInvalidKeyStore(Cert.SERVER_PEM.get().setKeyPath("/invalid.pem"), "java.nio.file.NoSuchFileException: ", "invalid.pem"); }
@Test public void testPKCS12MissingPassword() { testInvalidKeyStore(Cert.SERVER_PKCS12.get().setPassword(null), "Get Key failed: null", null); }
@Test public void testKeyCertMissingCertPath() { testInvalidKeyStore(Cert.SERVER_PEM.get().setCertPath(null), "Missing X.509 certificate", null); }
@Test public void testKeyCertInvalidCertPath() { testInvalidKeyStore(Cert.SERVER_PEM.get().setCertPath("/invalid.pem"), "java.nio.file.NoSuchFileException: ", "invalid.pem"); }
@Test public void testJKSInvalidPath() { testInvalidKeyStore(Cert.SERVER_JKS.get().setPath("/invalid.jks"), "java.nio.file.NoSuchFileException: ", "invalid.jks"); }
@Test public void testJKSInvalidPassword() { testInvalidKeyStore(Cert.SERVER_JKS.get().setPassword("wrongpassword"), "Keystore was tampered with, or password was incorrect", null); }
@Test public void testNoKeyCert() { testInvalidKeyStore(null, "Key/certificate is mandatory for SSL", null); }
@Test public void testPKCS12InvalidPassword() { testInvalidKeyStore(Cert.SERVER_PKCS12.get().setPassword("wrongpassword"), Arrays.asList( "failed to decrypt safe contents entry: javax.crypto.BadPaddingException: Given final block not properly padded", "keystore password was incorrect"), null); }
@Test public void testJKSInvalidPassword() { testInvalidKeyStore(Cert.SERVER_JKS.get().setPassword("wrongpassword"), "Keystore was tampered with, or password was incorrect", null); }
@Test public void testKeyCertInvalidCertPath() { testInvalidKeyStore(Cert.SERVER_PEM.get().setCertPath("/invalid.pem"), "java.nio.file.NoSuchFileException: ", "invalid.pem"); }
@Test public void testKeyCertMissingKeyPath() { testInvalidKeyStore(Cert.SERVER_PEM.get().setKeyPath(null), "Missing private key", null); }
@Test public void testJKSInvalidPath() { testInvalidKeyStore(Cert.SERVER_JKS.get().setPath("/invalid.jks"), "java.nio.file.NoSuchFileException: ", "invalid.jks"); }
@Test public void testPKCS12MissingPassword() { testInvalidKeyStore(Cert.SERVER_PKCS12.get().setPassword(null), "Get Key failed: null", null); }
@Test public void testJKSMissingPassword() { testInvalidKeyStore(Cert.SERVER_JKS.get().setPassword(null), "Password must not be null", null); }