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

8236671: NullPointerException in JKS keystore #144

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -291,7 +291,7 @@ public void engineSetKeyEntry(String alias, Key key, char[] password,
}

} catch (Exception e) {
throw new KeyStoreException(e.getMessage());
throw new KeyStoreException(e.getMessage(), e);
}
}
}
@@ -263,6 +263,9 @@ public void engineSetKeyEntry(String alias, Key key, char[] password,
if (!(key instanceof java.security.PrivateKey)) {
throw new KeyStoreException("Cannot store non-PrivateKeys");
}
if (password == null) {
throw new KeyStoreException("password can't be null");
}
try {
synchronized(entries) {
KeyEntry entry = new KeyEntry();
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -40,7 +40,7 @@

/*
* @test
* @bug 8048621 8133090 8167371
* @bug 8048621 8133090 8167371 8236671
* @summary Test basic operations with keystores (jks, jceks, pkcs12)
* @author Yu-Ching Valerie PENG
*/
@@ -181,6 +181,17 @@ public void runTest(String provider) throws Exception {
// create an empty key store
ks.load(null, null);

// unit test - test with null password
try {
ks.setKeyEntry(ALIAS_HEAD, privateKey, null,
new Certificate[] { cert });
} catch (KeyStoreException e) {
if (!e.getMessage().contains("password can\'t be null")) {
throw new RuntimeException("Unexpected message:" + e.getMessage());
}
// expected
}

// store the secret keys
for (int j = 0; j < numEntries; j++) {
ks.setKeyEntry(ALIAS_HEAD + j, privateKey, PASSWDK,