On Fri, 10 Apr 2026 08:07:23 GMT, Matthias Baesken <[email protected]> wrote:
> 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). Thanks for the reviews ! ------------- PR Comment: https://git.openjdk.org/jdk/pull/30666#issuecomment-4234492457
