author | jjiang |
Wed, 15 Aug 2018 18:41:18 +0800 | |
changeset 51460 | 97e361fe3433 |
parent 51245 | f095e3bc2d41 |
permissions | -rw-r--r-- |
48248
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
1 |
/* |
51245
f095e3bc2d41
8206258: [Test Error] sun/security/pkcs11 tests fail if NSS libs not found
jjiang
parents:
51213
diff
changeset
|
2 |
* Copyright (c) 2017, 2018, Red Hat, Inc. and/or its affiliates. |
48248
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
3 |
* |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
4 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
5 |
* |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
6 |
* This code is free software; you can redistribute it and/or modify it |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
7 |
* under the terms of the GNU General Public License version 2 only, as |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
8 |
* published by the Free Software Foundation. |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
9 |
* |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
10 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
11 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
12 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
13 |
* version 2 for more details (a copy is included in the LICENSE file that |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
14 |
* accompanied this code). |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
15 |
* |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
16 |
* You should have received a copy of the GNU General Public License version |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
17 |
* 2 along with this work; if not, write to the Free Software Foundation, |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
18 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
19 |
* |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
20 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
21 |
* or visit www.oracle.com if you need additional information or have any |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
22 |
* questions. |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
23 |
*/ |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
24 |
|
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
25 |
/* |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
26 |
* @test |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
27 |
* @bug 8165996 |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
28 |
* @summary Test NSS DB Sqlite |
51213 | 29 |
* @comment There is no NSS on Aix. |
30 |
* @requires os.family != "aix" |
|
51460
97e361fe3433
8164639: Configure PKCS11 tests to use user-supplied NSS libraries
jjiang
parents:
51245
diff
changeset
|
31 |
* @library /test/lib ../ |
48248
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
32 |
* @modules java.base/sun.security.rsa |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
33 |
* java.base/sun.security.provider |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
34 |
* java.base/sun.security.jca |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
35 |
* java.base/sun.security.tools.keytool |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
36 |
* java.base/sun.security.x509 |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
37 |
* java.base/com.sun.crypto.provider |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
38 |
* jdk.crypto.cryptoki/sun.security.pkcs11:+open |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
39 |
* @run main/othervm/timeout=120 TestNssDbSqlite |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
40 |
* @author Martin Balao (mbalao@redhat.com) |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
41 |
*/ |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
42 |
|
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
43 |
import java.security.PrivateKey; |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
44 |
import java.security.cert.Certificate; |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
45 |
import java.security.KeyStore; |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
46 |
import java.security.Provider; |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
47 |
import java.security.Signature; |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
48 |
|
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
49 |
import sun.security.rsa.SunRsaSign; |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
50 |
import sun.security.jca.ProviderList; |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
51 |
import sun.security.jca.Providers; |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
52 |
import sun.security.tools.keytool.CertAndKeyGen; |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
53 |
import sun.security.x509.X500Name; |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
54 |
|
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
55 |
public final class TestNssDbSqlite extends SecmodTest { |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
56 |
|
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
57 |
private static final boolean enableDebug = true; |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
58 |
|
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
59 |
private static Provider sunPKCS11NSSProvider; |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
60 |
private static Provider sunRsaSignProvider; |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
61 |
private static Provider sunJCEProvider; |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
62 |
private static KeyStore ks; |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
63 |
private static char[] passphrase = "test12".toCharArray(); |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
64 |
private static PrivateKey privateKey; |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
65 |
private static Certificate certificate; |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
66 |
|
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
67 |
public static void main(String[] args) throws Exception { |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
68 |
|
51245
f095e3bc2d41
8206258: [Test Error] sun/security/pkcs11 tests fail if NSS libs not found
jjiang
parents:
51213
diff
changeset
|
69 |
if (!initialize()) { |
f095e3bc2d41
8206258: [Test Error] sun/security/pkcs11 tests fail if NSS libs not found
jjiang
parents:
51213
diff
changeset
|
70 |
return; |
f095e3bc2d41
8206258: [Test Error] sun/security/pkcs11 tests fail if NSS libs not found
jjiang
parents:
51213
diff
changeset
|
71 |
} |
48248
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
72 |
|
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
73 |
if (enableDebug) { |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
74 |
System.out.println("SunPKCS11 provider: " + |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
75 |
sunPKCS11NSSProvider); |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
76 |
} |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
77 |
|
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
78 |
testRetrieveKeysFromKeystore(); |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
79 |
|
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
80 |
System.out.println("Test PASS - OK"); |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
81 |
} |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
82 |
|
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
83 |
private static void testRetrieveKeysFromKeystore() throws Exception { |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
84 |
|
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
85 |
String plainText = "known plain text"; |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
86 |
|
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
87 |
ks.setKeyEntry("root_ca_1", privateKey, passphrase, |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
88 |
new Certificate[]{certificate}); |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
89 |
PrivateKey k1 = (PrivateKey) ks.getKey("root_ca_1", passphrase); |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
90 |
|
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
91 |
Signature sS = Signature.getInstance( |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
92 |
"SHA256withRSA", sunPKCS11NSSProvider); |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
93 |
sS.initSign(k1); |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
94 |
sS.update(plainText.getBytes()); |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
95 |
byte[] generatedSignature = sS.sign(); |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
96 |
|
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
97 |
if (enableDebug) { |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
98 |
System.out.println("Generated signature: "); |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
99 |
for (byte b : generatedSignature) { |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
100 |
System.out.printf("0x%02x, ", (int)(b) & 0xFF); |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
101 |
} |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
102 |
System.out.println(""); |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
103 |
} |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
104 |
|
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
105 |
Signature sV = Signature.getInstance("SHA256withRSA", sunRsaSignProvider); |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
106 |
sV.initVerify(certificate); |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
107 |
sV.update(plainText.getBytes()); |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
108 |
if(!sV.verify(generatedSignature)){ |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
109 |
throw new Exception("Couldn't verify signature"); |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
110 |
} |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
111 |
} |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
112 |
|
51245
f095e3bc2d41
8206258: [Test Error] sun/security/pkcs11 tests fail if NSS libs not found
jjiang
parents:
51213
diff
changeset
|
113 |
private static boolean initialize() throws Exception { |
f095e3bc2d41
8206258: [Test Error] sun/security/pkcs11 tests fail if NSS libs not found
jjiang
parents:
51213
diff
changeset
|
114 |
return initializeProvider(); |
48248
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
115 |
} |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
116 |
|
51245
f095e3bc2d41
8206258: [Test Error] sun/security/pkcs11 tests fail if NSS libs not found
jjiang
parents:
51213
diff
changeset
|
117 |
private static boolean initializeProvider() throws Exception { |
48248
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
118 |
useSqlite(true); |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
119 |
if (!initSecmod()) { |
51245
f095e3bc2d41
8206258: [Test Error] sun/security/pkcs11 tests fail if NSS libs not found
jjiang
parents:
51213
diff
changeset
|
120 |
System.out.println("Cannot init security module database, skipping"); |
f095e3bc2d41
8206258: [Test Error] sun/security/pkcs11 tests fail if NSS libs not found
jjiang
parents:
51213
diff
changeset
|
121 |
return false; |
48248
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
122 |
} |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
123 |
|
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
124 |
sunPKCS11NSSProvider = getSunPKCS11(BASE + SEP + "nss-sqlite.cfg"); |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
125 |
sunJCEProvider = new com.sun.crypto.provider.SunJCE(); |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
126 |
sunRsaSignProvider = new SunRsaSign(); |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
127 |
Providers.setProviderList(ProviderList.newList( |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
128 |
sunJCEProvider, sunPKCS11NSSProvider, |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
129 |
new sun.security.provider.Sun(), sunRsaSignProvider)); |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
130 |
|
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
131 |
ks = KeyStore.getInstance("PKCS11-NSS-Sqlite", sunPKCS11NSSProvider); |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
132 |
ks.load(null, passphrase); |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
133 |
|
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
134 |
CertAndKeyGen gen = new CertAndKeyGen("RSA", "SHA256withRSA"); |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
135 |
gen.generate(2048); |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
136 |
privateKey = gen.getPrivateKey(); |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
137 |
certificate = gen.getSelfCertificate(new X500Name("CN=Me"), 365); |
51245
f095e3bc2d41
8206258: [Test Error] sun/security/pkcs11 tests fail if NSS libs not found
jjiang
parents:
51213
diff
changeset
|
138 |
|
f095e3bc2d41
8206258: [Test Error] sun/security/pkcs11 tests fail if NSS libs not found
jjiang
parents:
51213
diff
changeset
|
139 |
return true; |
48248
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
140 |
} |
55b9b1e184c6
8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite
weijun
parents:
diff
changeset
|
141 |
} |