Skip to content

Commit 73aae5e

Browse files
committed
Add debug method in pkcs11 ConfigurationException
Improve error reporting for SunPKCS11 provider initialization failures due to possible configuration errors. Output error messages when -Djava.security.debug=sunpkcs11 is used. Constructors are updated to call the debug method with the error message. Signed-off-by: Sarwat Shaheen <[email protected]>
1 parent f10368c commit 73aae5e

File tree

1 file changed

+14
-1
lines changed
  • src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11

1 file changed

+14
-1
lines changed

src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/Config.java

+14-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
/*
2727
* ===========================================================================
28-
* (c) Copyright IBM Corp. 2023, 2023 All Rights Reserved
28+
* (c) Copyright IBM Corp. 2023, 2025 All Rights Reserved
2929
* ===========================================================================
3030
*/
3131

@@ -37,6 +37,7 @@
3737
import java.nio.charset.StandardCharsets;
3838
import java.util.*;
3939

40+
import sun.security.util.Debug;
4041
import sun.security.util.PropertyExpander;
4142

4243
import sun.security.pkcs11.wrapper.*;
@@ -1084,11 +1085,23 @@ private void parseHandleStartupErrors(String keyword) throws IOException {
10841085
class ConfigurationException extends IOException {
10851086
@Serial
10861087
private static final long serialVersionUID = 254492758807673194L;
1088+
1089+
private static final Debug configDebug = Debug.getInstance("sunpkcs11");
1090+
1091+
private static void debug(String msg) {
1092+
// If debugging is enabled, use the Debug class for additional sunpkcs11 logging.
1093+
if (configDebug != null) {
1094+
configDebug.println(msg);
1095+
}
1096+
}
1097+
10871098
ConfigurationException(String msg) {
10881099
super(msg);
1100+
debug(msg);
10891101
}
10901102

10911103
ConfigurationException(String msg, Throwable e) {
10921104
super(msg, e);
1105+
debug(msg);
10931106
}
10941107
}

0 commit comments

Comments
 (0)