-
Bug
-
Resolution: Fixed
-
P2
-
11, 17, 19
-
b13
-
x86
-
windows_xp
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8317762 | 17.0.10 | Mat Carter | P2 | Resolved | Fixed | b01 |
JDK-8318052 | 11.0.22 | Mat Carter | P2 | Resolved | Fixed | b01 |
In some (if not all) cases the SunMSCAPI provider leaks keys. When getting the keys and building certificate chains the provider silently gets the keys as a test which are then freed. The Windows API for CryptAcquireCertificatePrivateKey details that the caller needs to release the key if the output value of pfCallerFreeProvOrNCryptKey is true. The existing code handled this case but did not use the correct free in all cases. There's a second output (pdwKeySpec) value which tells you whether to use CryptReleaseContext or NCryptFreeObject. However the current code always calls CryptReleaseContext.
Here's a repro case (watch the handle counts in the windows task manager grow) for both java.exe and lsass.exe
Note that this issue existed prior to the support for localmachine stores was added
import java.security.*;
class AcpTest {
public static void main(String[] args)
{
try {
while (true)
{
KeyStore keyStore = KeyStore.getInstance("Windows-MY");
keyStore.load(null, null);
}
} catch (Exception ex) {
System.out.println("Error!");
ex.printStackTrace();
}
}
}
Here's a repro case (watch the handle counts in the windows task manager grow) for both java.exe and lsass.exe
Note that this issue existed prior to the support for localmachine stores was added
import java.security.*;
class AcpTest {
public static void main(String[] args)
{
try {
while (true)
{
KeyStore keyStore = KeyStore.getInstance("Windows-MY");
keyStore.load(null, null);
}
} catch (Exception ex) {
System.out.println("Error!");
ex.printStackTrace();
}
}
}
- backported by
-
JDK-8317762 SunMSCAPI provider leaks memory and keys
-
- Resolved
-
-
JDK-8318052 SunMSCAPI provider leaks memory and keys
-
- Resolved
-
- links to
-
Commit openjdk/jdk11u-dev/94d3648b
-
Commit openjdk/jdk17u-dev/a393f258
-
Commit openjdk/jdk/c51d40cf
-
Review openjdk/jdk11u-dev/2174
-
Review openjdk/jdk17u-dev/1846
-
Review openjdk/jdk17u-dev/1848
-
Review openjdk/jdk/12891
(4 links to)