Currently in some specific Windows environment, I run into this error/exception 
(test sun/security/mscapi/EncodingMutability.java) :
java.security.ProviderException: java.security.KeyException: error 2, The 
system cannot find the file specified.


at 
jdk.crypto.mscapi/sun.security.mscapi.CKeyPairGenerator$RSA.generateKeyPair(CKeyPairGenerator.java:126)
at 
java.base/java.security.KeyPairGenerator$Delegate.generateKeyPair(KeyPairGenerator.java:723)
at EncodingMutability.main(EncodingMutability.java:38)
at 
java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:565)
at 
com.sun.javatest.regtest.agent.MainActionHelper$AgentVMRunnable.run(MainActionHelper.java:335)
at java.base/java.lang.Thread.run(Thread.java:1527)
Caused by: java.security.KeyException: error 2, The system cannot find the file 
specified.

at 
jdk.crypto.mscapi/sun.security.mscapi.CKeyPairGenerator$RSA.generateCKeyPair(Native
 Method)
at 
jdk.crypto.mscapi/sun.security.mscapi.CKeyPairGenerator$RSA.generateKeyPair(CKeyPairGenerator.java:121)


Unfortunately in the native generateCKeyPair method we get only the 
GetLastError output in the exception text. It would be better to also get a 
hint about the failing method CryptAcquireContext or CryptGenKey.
For this we could use the existing helper ThrowExceptionWithMessageAndErrcode .

---------
- [x] I confirm that I make this contribution in accordance with the [OpenJDK 
Interim AI Policy](https://openjdk.org/legal/ai).

-------------

Commit messages:
 - JDK-8381937

Changes: https://git.openjdk.org/jdk/pull/30666/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=30666&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8381937
  Stats: 3 lines in 1 file changed: 0 ins; 0 del; 3 mod
  Patch: https://git.openjdk.org/jdk/pull/30666.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/30666/head:pull/30666

PR: https://git.openjdk.org/jdk/pull/30666

Reply via email to