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

8231107: Allow store password to be null when saving a PKCS12 KeyStore #5950

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
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
8 changes: 6 additions & 2 deletions test/jdk/sun/security/pkcs12/EmptyPassword.java
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@
* @modules java.base/sun.security.tools.keytool
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add an @summary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll update the existing summary to @summary Testing empty (null, "", "\0") password behaviors.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.

* java.base/sun.security.x509
* @library /test/lib
* @summary Java Keystore fails to load PKCS12/PFX certificates created in WindowsServer2016
* @summary Testing empty (any of null, "", "\0") password behaviors
*/

import jdk.test.lib.Asserts;
@@ -54,14 +54,18 @@ public static void main(String[] args) throws Exception {
gen.getSelfCertificate(new X500Name("CN=Me"), 100)
});

// 8202299: interop before new char[0] and new char[1]
// 8202299: interop between new char[0] and new char[1]
store(ks, "p12", new char[1]);

// It can be loaded with password "".
ks = KeyStore.getInstance(new File("p12"), new char[0]);
Asserts.assertTrue(ks.getKey("a", new char[0]) != null);
Asserts.assertTrue(ks.getCertificate("a") != null);

ks = KeyStore.getInstance(new File("p12"), new char[1]);
Asserts.assertTrue(ks.getKey("a", new char[1]) != null);
Asserts.assertTrue(ks.getCertificate("a") != null);

// 8231107: Store with null password makes it password-less
store(ks, "p00", null);