8328785: IOException: Symbol not found: C_GetInterface for PKCS11 interface prior to V3.0
Reviewed-by: djelinski, weijun
This commit is contained in:
parent
316361b95c
commit
6276789fb5
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
|
||||
/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
|
||||
@ -103,7 +103,6 @@ JNIEXPORT jobject JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_connect
|
||||
/*
|
||||
* Load the PKCS #11 DLL
|
||||
*/
|
||||
dlerror(); /* clear any old error message not fetched */
|
||||
#ifdef DEBUG
|
||||
hModule = dlopen(libraryNameStr, RTLD_NOW);
|
||||
#else
|
||||
@ -124,9 +123,6 @@ JNIEXPORT jobject JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_connect
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// clear any old error message not fetched
|
||||
dlerror();
|
||||
|
||||
#ifdef DEBUG
|
||||
C_GetInterfaceList = (CK_C_GetInterfaceList) dlsym(hModule,
|
||||
"C_GetInterfaceList");
|
||||
@ -158,47 +154,42 @@ JNIEXPORT jobject JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_connect
|
||||
}
|
||||
#endif
|
||||
|
||||
if (jGetFunctionList != NULL) {
|
||||
// if none specified, then we try 3.0 API first before trying 2.40
|
||||
if (jGetFunctionList == NULL) {
|
||||
C_GetInterface = (CK_C_GetInterface) dlsym(hModule, "C_GetInterface");
|
||||
if (C_GetInterface != NULL) {
|
||||
TRACE0("Connect: Found C_GetInterface func\n");
|
||||
rv = (C_GetInterface)(NULL, NULL, &interface, 0L);
|
||||
// don't use ckAssertReturnValueOK as we want to continue trying
|
||||
// C_GetFunctionList() or method named by "getFunctionListStr"
|
||||
if (rv == CKR_OK) {
|
||||
goto setModuleData;
|
||||
}
|
||||
}
|
||||
getFunctionListStr = "C_GetFunctionList";
|
||||
} else {
|
||||
getFunctionListStr = (*env)->GetStringUTFChars(env,
|
||||
jGetFunctionList, 0);
|
||||
if (getFunctionListStr == NULL) {
|
||||
goto cleanup;
|
||||
}
|
||||
C_GetFunctionList = (CK_C_GetFunctionList) dlsym(hModule,
|
||||
}
|
||||
|
||||
dlerror(); // clear any old error message not fetched
|
||||
C_GetFunctionList = (CK_C_GetFunctionList) dlsym(hModule,
|
||||
getFunctionListStr);
|
||||
if (C_GetFunctionList == NULL) {
|
||||
if ((systemErrorMessage = dlerror()) != NULL){
|
||||
TRACE2("Connect: error finding %s func: %s\n", getFunctionListStr,
|
||||
systemErrorMessage);
|
||||
p11ThrowIOException(env, systemErrorMessage);
|
||||
goto cleanup;
|
||||
}
|
||||
if (C_GetFunctionList == NULL) {
|
||||
} else {
|
||||
TRACE1("Connect: No %s func\n", getFunctionListStr);
|
||||
p11ThrowIOException(env, "ERROR: C_GetFunctionList == NULL");
|
||||
goto cleanup;
|
||||
}
|
||||
TRACE1("Connect: Found %s func\n", getFunctionListStr);
|
||||
} else {
|
||||
// if none specified, then we try 3.0 API first before trying 2.40
|
||||
C_GetInterface = (CK_C_GetInterface) dlsym(hModule, "C_GetInterface");
|
||||
if ((C_GetInterface != NULL) && (dlerror() == NULL)) {
|
||||
TRACE0("Connect: Found C_GetInterface func\n");
|
||||
rv = (C_GetInterface)(NULL, NULL, &interface, 0L);
|
||||
if (ckAssertReturnValueOK(env, rv) == CK_ASSERT_OK) {
|
||||
goto setModuleData;
|
||||
}
|
||||
}
|
||||
C_GetFunctionList = (CK_C_GetFunctionList) dlsym(hModule,
|
||||
"C_GetFunctionList");
|
||||
if ((systemErrorMessage = dlerror()) != NULL){
|
||||
p11ThrowIOException(env, systemErrorMessage);
|
||||
goto cleanup;
|
||||
}
|
||||
if (C_GetFunctionList == NULL) {
|
||||
TRACE0("Connect: No C_GetFunctionList func\n");
|
||||
p11ThrowIOException(env, "ERROR: C_GetFunctionList == NULL");
|
||||
goto cleanup;
|
||||
}
|
||||
TRACE0("Connect: Found C_GetFunctionList func\n");
|
||||
goto cleanup;
|
||||
}
|
||||
TRACE1("Connect: Found %s func\n", getFunctionListStr);
|
||||
|
||||
setModuleData:
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user