jdk_security3_0_FAILED InvalidKeyException: Key must not be null & KeyStoreException: Cannot store non-PrivateKeys #15221

@JasonFengJ9

Description

Failure link

From an internal build ( ub20x64rt1-3 ):

openjdk version "1.8.0_342"
IBM Semeru Runtime Open Edition (build 1.8.0_342-b03)
Eclipse OpenJ9 VM (build v0.33.0-release-bf978d503, JRE 1.8.0 Linux amd64-64-Bit Compressed References 20220602_396 (JIT enabled, AOT enabled)
OpenJ9   - bf978d503
OMR      - e7d85499b
JCL      - b43a04972a based on jdk8u342-b03)

Rerun in Grinder - Change TARGET to run only the failed test targets.

Optional info

Failure output (captured from console output)

[2022-06-02T20:13:58.406Z] Running test jdk_security3_0 ...
[2022-06-02T20:13:58.406Z] ===============================================
[2022-06-02T20:13:58.406Z] jdk_security3_0 Start Time: Thu Jun  2 13:13:58 2022 Epoch Time (ms): 1654200838176
[2022-06-02T20:13:58.406Z] variation: Mode150
[2022-06-02T20:13:58.406Z] JVM_OPTIONS:  -XX:+UseCompressedOops 
[2022-06-02T20:22:59.925Z] TEST: sun/security/pkcs11/Secmod/GetPrivateKey.java
16:22:59  ACTION: main -- Failed. Execution failed: `main' threw exception: java.security.InvalidKeyException: Key must not be null
16:22:59  REASON: User specified action: run main/othervm GetPrivateKey 
16:22:59  TIME:   0.295 seconds
16:22:59  messages:
16:22:59  command: main GetPrivateKey
16:22:59  reason: User specified action: run main/othervm GetPrivateKey 
16:22:59  Mode: othervm [/othervm specified]
16:22:59  elapsed time (seconds): 0.295
16:22:59  configuration:
16:22:59  STDOUT:
16:22:59  libsoftokn3 version = 3.491.  ECC Basic.
16:22:59  SunPKCS11-NSSKeyStore version 1.8
16:22:59  entries: 0
16:22:59  []
16:22:59  null
16:22:59  Signing...
[2022-06-02T20:22:59.926Z] STDERR:
[2022-06-02T20:22:59.926Z] java.security.InvalidKeyException: Key must not be null
[2022-06-02T20:22:59.926Z] 	at sun.security.rsa.RSAKeyFactory.toRSAKey(RSAKeyFactory.java:119)
[2022-06-02T20:22:59.926Z] 	at sun.security.rsa.RSASignature.engineInitSign(RSASignature.java:111)
[2022-06-02T20:22:59.926Z] 	at sun.security.rsa.RSASignature.engineInitSign(RSASignature.java:103)
[2022-06-02T20:22:59.926Z] 	at java.security.Signature$Delegate.tryOperation(Signature.java:1286)
[2022-06-02T20:22:59.926Z] 	at java.security.Signature$Delegate.chooseProvider(Signature.java:1234)
[2022-06-02T20:22:59.926Z] 	at java.security.Signature$Delegate.engineInitSign(Signature.java:1332)
[2022-06-02T20:22:59.926Z] 	at java.security.Signature.initSign(Signature.java:621)
[2022-06-02T20:22:59.926Z] 	at GetPrivateKey.main(GetPrivateKey.java:79)
[2022-06-02T20:22:59.926Z] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[2022-06-02T20:22:59.926Z] 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[2022-06-02T20:22:59.926Z] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[2022-06-02T20:22:59.926Z] 	at java.lang.reflect.Method.invoke(Method.java:498)
[2022-06-02T20:22:59.926Z] 	at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:127)
[2022-06-02T20:22:59.926Z] 	at java.lang.Thread.run(Thread.java:827)
[2022-06-02T20:22:59.926Z] 
[2022-06-02T20:22:59.926Z] JavaTest Message: Test threw exception: java.security.InvalidKeyException: Key must not be null
[2022-06-02T20:22:59.926Z] TEST: sun/security/pkcs11/Secmod/JksSetPrivateKey.java
16:22:59  ACTION: main -- Failed. Execution failed: `main' threw exception: java.lang.IllegalArgumentException: Private key must be accompanied by certificate chain
16:22:59  REASON: User specified action: run main/othervm JksSetPrivateKey 
16:22:59  TIME:   0.273 seconds
16:22:59  messages:
16:22:59  command: main JksSetPrivateKey
16:22:59  reason: User specified action: run main/othervm JksSetPrivateKey 
16:22:59  Mode: othervm [/othervm specified]
16:22:59  elapsed time (seconds): 0.273
16:22:59  configuration:
16:22:59  STDOUT:
16:22:59  libsoftokn3 version = 3.491.  ECC Basic.
16:22:59  SunPKCS11-NSSKeyStore version 1.8
16:22:59  entries: 0
16:22:59  []
16:22:59  null
[2022-06-02T20:22:59.927Z] STDERR:
[2022-06-02T20:22:59.927Z] java.security.KeyStoreException: Cannot store non-PrivateKeys
[2022-06-02T20:22:59.927Z] java.lang.IllegalArgumentException: Private key must be accompanied by certificate chain
[2022-06-02T20:22:59.927Z] 	at java.security.KeyStore.setKeyEntry(KeyStore.java:1136)
[2022-06-02T20:22:59.927Z] 	at JksSetPrivateKey.main(JksSetPrivateKey.java:86)
[2022-06-02T20:22:59.927Z] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[2022-06-02T20:22:59.927Z] 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[2022-06-02T20:22:59.927Z] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[2022-06-02T20:22:59.927Z] 	at java.lang.reflect.Method.invoke(Method.java:498)
[2022-06-02T20:22:59.927Z] 	at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:127)
[2022-06-02T20:22:59.927Z] 	at java.lang.Thread.run(Thread.java:827)
[2022-06-02T20:22:59.927Z] 
[2022-06-02T20:22:59.927Z] JavaTest Message: Test threw exception: java.lang.IllegalArgumentException: Private key must be accompanied by certificate chain
[2022-06-02T21:07:52.131Z] Test results: passed: 603; failed: 2
[2022-06-02T21:07:52.131Z] Report written to /home/jenkins/workspace/Test_openjdk8_j9_extended.openjdk_x86-64_linux/jvmtest/openjdk/report/html/report.html
[2022-06-02T21:07:52.131Z] Results written to /home/jenkins/workspace/Test_openjdk8_j9_extended.openjdk_x86-64_linux/aqa-tests/TKG/output_16541956331725/jdk_security3_0/work
[2022-06-02T21:07:52.131Z] Error: Some tests failed or other problems occurred.
[2022-06-02T21:07:52.131Z] 
[2022-06-02T21:07:52.131Z] jdk_security3_0_FAILED

50x grinder - job/Grinder/24536/ & job/Grinder/24537/ - all passed