Skip to content
Permalink
Browse files
8237804: sun/security/mscapi tests fail with "Key pair not generated,…
… alias <nnnnnn> already exists"

Reviewed-by: mullan
  • Loading branch information
wangweij committed Feb 5, 2020
1 parent 029f547 commit 06579fcefa3342586532ce7a41a3b4287b9da376
Showing with 24 additions and 6 deletions.
  1. +13 −4 test/jdk/sun/security/mscapi/KeyAlgorithms.java
  2. +11 −2 test/jdk/sun/security/mscapi/PublicKeyInterop.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2020, 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
@@ -23,7 +23,7 @@

/**
* @test
* @bug 8213009
* @bug 8213009 8237804
* @summary Make sure SunMSCAPI keys have correct algorithm names
* @requires os.family == "windows"
* @library /test/lib
@@ -42,6 +42,7 @@

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

cleanup();
SecurityTools.keytool("-genkeypair",
"-storetype", "Windows-My",
"-keyalg", ALG,
@@ -52,13 +53,21 @@ public static void main(String[] arg) throws Exception {
try {
test(loadKeysFromKeyStore());
} finally {
cleanup();
}

test(generateKeys());
}

private static void cleanup() {
try {
KeyStore ks = KeyStore.getInstance("Windows-MY");
ks.load(null, null);
ks.deleteEntry(ALIAS);
ks.store(null, null);
} catch (Exception e) {
System.out.println("No such entry.");
}

test(generateKeys());
}

static KeyPair loadKeysFromKeyStore() throws Exception {
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2020, 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
@@ -23,7 +23,7 @@

/**
* @test
* @bug 6888925 8180570
* @bug 6888925 8180570 8237804
* @summary SunMSCAPI's Cipher can't use RSA public keys obtained from other sources.
* @requires os.family == "windows"
* @library /test/lib
@@ -45,6 +45,7 @@

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

cleanup();
SecurityTools.keytool("-genkeypair",
"-storetype", "Windows-My",
"-keyalg", "RSA",
@@ -55,10 +56,18 @@ public static void main(String[] arg) throws Exception {
try {
run();
} finally {
cleanup();
}
}

private static void cleanup() {
try {
KeyStore ks = KeyStore.getInstance("Windows-MY");
ks.load(null, null);
ks.deleteEntry("6888925");
ks.store(null, null);
} catch (Exception e) {
System.out.println("No such entry.");
}
}

0 comments on commit 06579fc

Please sign in to comment.