-
Bug
-
Resolution: Fixed
-
P3
-
17, 20, 21
-
b27
-
x86_64
-
windows
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8358579 | 21.0.9-oracle | Sean Coffey | P3 | Resolved | Fixed | master |
JDK-8359452 | 21.0.9 | Satyen Subramaniam | P3 | Resolved | Fixed | master |
JDK-8358583 | 17.0.17-oracle | Sean Coffey | P3 | Resolved | Fixed | master |
JDK-8358584 | 11.0.29-oracle | Sean Coffey | P3 | Resolved | Fixed | master |
OS: Windows 11 version 22H2, or Windows Server 2022
OpenJDK: 17.0.8, or 20.0.2
A DESCRIPTION OF THE PROBLEM :
The enhancement developed to allow keystore access provider SunMSCAPI to access the Windows Local Computer keystore,
https://bugs.openjdk.org/browse/JDK-6782021
But with non-elevated access, the SunMSCAPI provider fails to access a read only private key from the Local Computer certificate store.
StackOverflow user "Andreas Gusenbauer" posted a question on this issue in January, 2023:
https://stackoverflow.com/questions/75255985/java-keystore-type-windows-my-root-localmachine-requires-administrator-permissio
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
The StackOverflow post includes an answer from user "Snaps-A-Lot", which includes instructions on how to reproduce the issue complete with images and references. But for this bug report, here is a top-down written instruction:
To reproduce the issue:
1) Login to Windows using an account with membership in the local Administrators group.
2) Create a self signed code signing certificate using the Powershell:
$cert = New-SelfSignedCertificate -DNSName "
3) Open the Control Panel, search for "certificates", click Manage Computer Certificates, expand Personal Certificates, right click the certificate issued to "
4) Install a recent version of Visual Studio, such as Visual Studio 2019, if it is not already installed. Locate singtool.exe on the system, and add its folder to the Path.
5) Install OpenJDK 17.0.8, if it is not already installed. Add its "bin" folder to the Path.
6) Open a non-elevated (Not "Administrator"" command prompt.
7) Create a temporary folder, and make it current:
md C:\temp\
cd C:\temp\
8) Copy any EXE file to the temporary folder, and rename it to MyApp.exe.
9) Copy any JAR file to the temporary folder, and rename it to MyPkg.jar.
10) From the non-elevated command prompt, enter the following commands:
signtool sign /sm /i "
jarsigner -keystore NONE -storetype Windows-MY-LocalMachine -providerClass sun.security.mscapi.SunMSCAPI MyPkg.jar
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
C:\temp\
Done Adding Additional Store
Successfully signed: MyApp.exe
C:\temp\
jar signed.
ACTUAL -
Microsoft's signtool.exe successfully complete a code signature based on a read only ky from the Windows Local Computer keystore:, while the OpenJDK jarsigner.exe utility fails to do likewise:
C:\temp\
Done Adding Additional Store
Successfully signed: MyApp.exe
C:\temp\
jarsigner error: java.lang.RuntimeException: keystore load: java.security.KeyStoreException: error 5, Access is denied.
CUSTOMER SUBMITTED WORKAROUND :
There is no true workaround for a high security environment, since the functionality added for
Running the test from an elevated prompt will yield the expected success, but that would violate basic security policy due to the requirement for the user to be a member of the Local Administrators group.
To proceed with signing code, a better approach is to revert to using the "Windows My-CurrentUser" key store (or simply "Windows My") keystore, as was done prior to the
FREQUENCY : always
- backported by
-
JDK-8358579 SunMSCAPI cannot read Local Computer certs w/o Windows elevation
-
- Resolved
-
-
JDK-8358583 SunMSCAPI cannot read Local Computer certs w/o Windows elevation
-
- Resolved
-
-
JDK-8358584 SunMSCAPI cannot read Local Computer certs w/o Windows elevation
-
- Resolved
-
-
JDK-8359452 SunMSCAPI cannot read Local Computer certs w/o Windows elevation
-
- Resolved
-
- duplicates
-
JDK-8351895 Backport request of fix for reading Local Computer certs w/o Windows elevation
-
- Closed
-
- relates to
-
JDK-6782021 It is not possible to read local computer certificates with the SunMSCAPI provider
-
- Resolved
-
- links to
-
Commit(master) openjdk/jdk21u-dev/96866ce3
-
Commit(master) openjdk/jdk/db535c86
-
Review(master) openjdk/jdk17u-dev/3647
-
Review(master) openjdk/jdk21u-dev/1860
-
Review(master) openjdk/jdk/16687