|
|
ecab97 |
# HG changeset patch
|
|
|
ecab97 |
# User mbalao
|
|
|
ecab97 |
# Date 1529971845 -28800
|
|
|
ecab97 |
# Tue Jun 26 08:10:45 2018 +0800
|
|
|
ecab97 |
# Node ID e9c20b7250cd98d16a67f2a30b34284c2caa01dc
|
|
|
ecab97 |
# Parent 9f1aa2e38d90dd60522237d7414af6bdcf03c4ff
|
|
|
ecab97 |
8195607, PR3776: sun/security/pkcs11/Secmod/TestNssDbSqlite.java failed with "NSS initialization failed" on NSS 3.34.1
|
|
|
ecab97 |
Reviewed-by: valeriep, weijun
|
|
|
ecab97 |
|
|
|
ecab97 |
diff --git openjdk.orig/jdk/src/share/classes/sun/security/pkcs11/Secmod.java openjdk/jdk/src/share/classes/sun/security/pkcs11/Secmod.java
|
|
|
ecab97 |
--- openjdk.orig/jdk/src/share/classes/sun/security/pkcs11/Secmod.java
|
|
|
ecab97 |
+++ openjdk/jdk/src/share/classes/sun/security/pkcs11/Secmod.java
|
|
|
ecab97 |
@@ -197,7 +197,7 @@
|
|
|
ecab97 |
|
|
|
ecab97 |
if (configDir != null) {
|
|
|
ecab97 |
String configDirPath = null;
|
|
|
ecab97 |
- String sqlPrefix = "sql:/";
|
|
|
ecab97 |
+ String sqlPrefix = "sql:";
|
|
|
ecab97 |
if (!configDir.startsWith(sqlPrefix)) {
|
|
|
ecab97 |
configDirPath = configDir;
|
|
|
ecab97 |
} else {
|
|
|
ecab97 |
diff --git openjdk.orig/jdk/src/share/native/sun/security/pkcs11/j2secmod.c openjdk/jdk/src/share/native/sun/security/pkcs11/j2secmod.c
|
|
|
ecab97 |
--- openjdk.orig/jdk/src/share/native/sun/security/pkcs11/j2secmod.c
|
|
|
ecab97 |
+++ openjdk/jdk/src/share/native/sun/security/pkcs11/j2secmod.c
|
|
|
ecab97 |
@@ -69,9 +69,14 @@
|
|
|
ecab97 |
int res = 0;
|
|
|
ecab97 |
FPTR_Initialize initialize =
|
|
|
ecab97 |
(FPTR_Initialize)findFunction(env, jHandle, "NSS_Initialize");
|
|
|
ecab97 |
+ #ifdef SECMOD_DEBUG
|
|
|
ecab97 |
+ FPTR_GetError getError =
|
|
|
ecab97 |
+ (FPTR_GetError)findFunction(env, jHandle, "PORT_GetError");
|
|
|
ecab97 |
+ #endif // SECMOD_DEBUG
|
|
|
ecab97 |
unsigned int flags = 0x00;
|
|
|
ecab97 |
const char *configDir = NULL;
|
|
|
ecab97 |
const char *functionName = NULL;
|
|
|
ecab97 |
+ const char *configFile = NULL;
|
|
|
ecab97 |
|
|
|
ecab97 |
/* If we cannot initialize, exit now */
|
|
|
ecab97 |
if (initialize == NULL) {
|
|
|
ecab97 |
@@ -97,13 +102,18 @@
|
|
|
ecab97 |
flags = 0x20; // NSS_INIT_OPTIMIZESPACE flag
|
|
|
ecab97 |
}
|
|
|
ecab97 |
|
|
|
ecab97 |
+ configFile = "secmod.db";
|
|
|
ecab97 |
+ if (configDir != NULL && strncmp("sql:", configDir, 4U) == 0) {
|
|
|
ecab97 |
+ configFile = "pkcs11.txt";
|
|
|
ecab97 |
+ }
|
|
|
ecab97 |
+
|
|
|
ecab97 |
/*
|
|
|
ecab97 |
* If the NSS_Init function is requested then call NSS_Initialize to
|
|
|
ecab97 |
* open the Cert, Key and Security Module databases, read only.
|
|
|
ecab97 |
*/
|
|
|
ecab97 |
if (strcmp("NSS_Init", functionName) == 0) {
|
|
|
ecab97 |
flags = flags | 0x01; // NSS_INIT_READONLY flag
|
|
|
ecab97 |
- res = initialize(configDir, "", "", "secmod.db", flags);
|
|
|
ecab97 |
+ res = initialize(configDir, "", "", configFile, flags);
|
|
|
ecab97 |
|
|
|
ecab97 |
/*
|
|
|
ecab97 |
* If the NSS_InitReadWrite function is requested then call
|
|
|
ecab97 |
@@ -111,7 +121,7 @@
|
|
|
ecab97 |
* read/write.
|
|
|
ecab97 |
*/
|
|
|
ecab97 |
} else if (strcmp("NSS_InitReadWrite", functionName) == 0) {
|
|
|
ecab97 |
- res = initialize(configDir, "", "", "secmod.db", flags);
|
|
|
ecab97 |
+ res = initialize(configDir, "", "", configFile, flags);
|
|
|
ecab97 |
|
|
|
ecab97 |
/*
|
|
|
ecab97 |
* If the NSS_NoDB_Init function is requested then call
|
|
|
ecab97 |
@@ -137,6 +147,13 @@
|
|
|
ecab97 |
(*env)->ReleaseStringUTFChars(env, jConfigDir, configDir);
|
|
|
ecab97 |
}
|
|
|
ecab97 |
dprintf1("-res: %d\n", res);
|
|
|
ecab97 |
+ #ifdef SECMOD_DEBUG
|
|
|
ecab97 |
+ if (res == -1) {
|
|
|
ecab97 |
+ if (getError != NULL) {
|
|
|
ecab97 |
+ dprintf1("-NSS error: %d\n", getError());
|
|
|
ecab97 |
+ }
|
|
|
ecab97 |
+ }
|
|
|
ecab97 |
+ #endif // SECMOD_DEBUG
|
|
|
ecab97 |
|
|
|
ecab97 |
return (res == 0) ? JNI_TRUE : JNI_FALSE;
|
|
|
ecab97 |
}
|
|
|
ecab97 |
diff --git openjdk.orig/jdk/src/solaris/native/sun/security/pkcs11/j2secmod_md.h openjdk/jdk/src/solaris/native/sun/security/pkcs11/j2secmod_md.h
|
|
|
ecab97 |
--- openjdk.orig/jdk/src/solaris/native/sun/security/pkcs11/j2secmod_md.h
|
|
|
ecab97 |
+++ openjdk/jdk/src/solaris/native/sun/security/pkcs11/j2secmod_md.h
|
|
|
ecab97 |
@@ -34,6 +34,10 @@
|
|
|
ecab97 |
const char *certPrefix, const char *keyPrefix,
|
|
|
ecab97 |
const char *secmodName, unsigned int flags);
|
|
|
ecab97 |
|
|
|
ecab97 |
+#ifdef SECMOD_DEBUG
|
|
|
ecab97 |
+typedef int (*FPTR_GetError)(void);
|
|
|
ecab97 |
+#endif //SECMOD_DEBUG
|
|
|
ecab97 |
+
|
|
|
ecab97 |
// in secmod.h
|
|
|
ecab97 |
//extern SECMODModule *SECMOD_LoadModule(char *moduleSpec,SECMODModule *parent,
|
|
|
ecab97 |
// PRBool recurse);
|
|
|
ecab97 |
diff --git openjdk.orig/jdk/test/sun/security/pkcs11/Secmod/pkcs11.txt openjdk/jdk/test/sun/security/pkcs11/Secmod/pkcs11.txt
|
|
|
ecab97 |
new file mode 100644
|
|
|
ecab97 |
--- /dev/null
|
|
|
ecab97 |
+++ openjdk/jdk/test/sun/security/pkcs11/Secmod/pkcs11.txt
|
|
|
ecab97 |
@@ -0,0 +1,4 @@
|
|
|
ecab97 |
+library=
|
|
|
ecab97 |
+name=NSS Internal PKCS #11 Module
|
|
|
ecab97 |
+parameters=configdir='sql:./tmpdb' certPrefix='' keyPrefix='' secmod='' flags= updatedir='' updateCertPrefix='' updateKeyPrefix='' updateid='' updateTokenDescription=''
|
|
|
ecab97 |
+NSS=Flags=internal,critical trustOrder=75 cipherOrder=100 slotParams=(1={slotFlags=[RSA,DSA,DH,RC2,RC4,DES,RANDOM,SHA1,MD5,MD2,SSL,TLS,AES,Camellia,SEED,SHA256,SHA512] askpw=any timeout=30})
|
|
|
ecab97 |
diff --git openjdk.orig/jdk/test/sun/security/pkcs11/SecmodTest.java openjdk/jdk/test/sun/security/pkcs11/SecmodTest.java
|
|
|
ecab97 |
--- openjdk.orig/jdk/test/sun/security/pkcs11/SecmodTest.java
|
|
|
ecab97 |
+++ openjdk/jdk/test/sun/security/pkcs11/SecmodTest.java
|
|
|
ecab97 |
@@ -55,7 +55,7 @@
|
|
|
ecab97 |
|
|
|
ecab97 |
DBDIR = System.getProperty("test.classes", ".") + SEP + "tmpdb";
|
|
|
ecab97 |
if (useSqlite) {
|
|
|
ecab97 |
- System.setProperty("pkcs11test.nss.db", "sql:/" + DBDIR);
|
|
|
ecab97 |
+ System.setProperty("pkcs11test.nss.db", "sql:" + DBDIR);
|
|
|
ecab97 |
} else {
|
|
|
ecab97 |
System.setProperty("pkcs11test.nss.db", DBDIR);
|
|
|
ecab97 |
}
|
|
|
ecab97 |
@@ -67,6 +67,7 @@
|
|
|
ecab97 |
if (useSqlite) {
|
|
|
ecab97 |
copyFile("key4.db", BASE, DBDIR);
|
|
|
ecab97 |
copyFile("cert9.db", BASE, DBDIR);
|
|
|
ecab97 |
+ copyFile("pkcs11.txt", BASE, DBDIR);
|
|
|
ecab97 |
} else {
|
|
|
ecab97 |
copyFile("secmod.db", BASE, DBDIR);
|
|
|
ecab97 |
copyFile("key3.db", BASE, DBDIR);
|