Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a long password on generated in-memory KeyStore #4907

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/main/java/io/vertx/core/net/impl/KeyStoreHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
public class KeyStoreHelper {

// Dummy password for encrypting pem based stores in memory
public static final String DUMMY_PASSWORD = "dummy";
public static final String DUMMY_PASSWORD = "dummdummydummydummydummydummydummy"; // at least 32 characters for compat with FIPS mode
private static final String DUMMY_CERT_ALIAS = "cert-";

private static final Pattern BEGIN_PATTERN = Pattern.compile("-----BEGIN ([A-Z ]+)-----");
Expand Down Expand Up @@ -159,10 +159,10 @@ public static KeyManagerFactory toKeyManagerFactory(X509KeyManager mgr) throws E
String keyStoreType = KeyStore.getDefaultType();
KeyStore ks = KeyStore.getInstance(keyStoreType);
ks.load(null, null);
ks.setKeyEntry("key", mgr.getPrivateKey(null), new char[0], mgr.getCertificateChain(null));
ks.setKeyEntry("key", mgr.getPrivateKey(null), DUMMY_PASSWORD.toCharArray(), mgr.getCertificateChain(null));
String keyAlgorithm = KeyManagerFactory.getDefaultAlgorithm();
KeyManagerFactory kmf = KeyManagerFactory.getInstance(keyAlgorithm);
kmf.init(ks, new char[0]);
kmf.init(ks, DUMMY_PASSWORD.toCharArray());
return kmf;
}

Expand Down
4 changes: 2 additions & 2 deletions src/test/java/io/vertx/core/net/KeyStoreHelperTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ private void assertKeyType(KeyStore store, Class<?> expectedKeyType) throws KeyS
assertTrue(store.size() > 0);
for (Enumeration<String> e = store.aliases(); e.hasMoreElements(); ) {
String alias = e.nextElement();
// "dummy" is the password set by KeyStoreHelper when importing the
// "dummdummydummydummydummydummydummy" is the password set by KeyStoreHelper when importing the
// keys into the internal key store
assertThat(store.getKey(alias, "dummy".toCharArray()), instanceOf(expectedKeyType));
assertThat(store.getKey(alias, "dummdummydummydummydummydummydummy".toCharArray()), instanceOf(expectedKeyType));
assertThat(store.getCertificate(alias), instanceOf(X509Certificate.class));
}
}
Expand Down