Skip to content

Commit 06579fc

Browse files
committed
8237804: sun/security/mscapi tests fail with "Key pair not generated, alias <nnnnnn> already exists"
Reviewed-by: mullan
1 parent 029f547 commit 06579fc

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

test/jdk/sun/security/mscapi/KeyAlgorithms.java

+13-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
2323

2424
/**
2525
* @test
26-
* @bug 8213009
26+
* @bug 8213009 8237804
2727
* @summary Make sure SunMSCAPI keys have correct algorithm names
2828
* @requires os.family == "windows"
2929
* @library /test/lib
@@ -42,6 +42,7 @@ public class KeyAlgorithms {
4242

4343
public static void main(String[] arg) throws Exception {
4444

45+
cleanup();
4546
SecurityTools.keytool("-genkeypair",
4647
"-storetype", "Windows-My",
4748
"-keyalg", ALG,
@@ -52,13 +53,21 @@ public static void main(String[] arg) throws Exception {
5253
try {
5354
test(loadKeysFromKeyStore());
5455
} finally {
56+
cleanup();
57+
}
58+
59+
test(generateKeys());
60+
}
61+
62+
private static void cleanup() {
63+
try {
5564
KeyStore ks = KeyStore.getInstance("Windows-MY");
5665
ks.load(null, null);
5766
ks.deleteEntry(ALIAS);
5867
ks.store(null, null);
68+
} catch (Exception e) {
69+
System.out.println("No such entry.");
5970
}
60-
61-
test(generateKeys());
6271
}
6372

6473
static KeyPair loadKeysFromKeyStore() throws Exception {

test/jdk/sun/security/mscapi/PublicKeyInterop.java

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
2323

2424
/**
2525
* @test
26-
* @bug 6888925 8180570
26+
* @bug 6888925 8180570 8237804
2727
* @summary SunMSCAPI's Cipher can't use RSA public keys obtained from other sources.
2828
* @requires os.family == "windows"
2929
* @library /test/lib
@@ -45,6 +45,7 @@ public class PublicKeyInterop {
4545

4646
public static void main(String[] arg) throws Exception {
4747

48+
cleanup();
4849
SecurityTools.keytool("-genkeypair",
4950
"-storetype", "Windows-My",
5051
"-keyalg", "RSA",
@@ -55,10 +56,18 @@ public static void main(String[] arg) throws Exception {
5556
try {
5657
run();
5758
} finally {
59+
cleanup();
60+
}
61+
}
62+
63+
private static void cleanup() {
64+
try {
5865
KeyStore ks = KeyStore.getInstance("Windows-MY");
5966
ks.load(null, null);
6067
ks.deleteEntry("6888925");
6168
ks.store(null, null);
69+
} catch (Exception e) {
70+
System.out.println("No such entry.");
6271
}
6372
}
6473

0 commit comments

Comments
 (0)