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). This pull request has now been integrated. Changeset: 78a6aa9c Author: Matthias Baesken <[email protected]> URL: https://git.openjdk.org/jdk/commit/78a6aa9c7a907fe3375cd20e45bb293b5d15732e Stats: 3 lines in 1 file changed: 0 ins; 0 del; 3 mod 8381937: Make exceptions in Java_sun_security_mscapi_CKeyPairGenerator generateCKeyPair more specific Reviewed-by: mdoerr, lucy ------------- PR: https://git.openjdk.org/jdk/pull/30666
