Skip to content

Commit 8971cb5

Browse files
martinuygnu-andrew
authored andcommitted
RH1818909: Set default keystore type for PKCS11 provider in FIPS mode
1 parent 8e5a697 commit 8971cb5

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

src/java.base/share/classes/java/security/SystemConfigurator.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,33 @@ static boolean configure(Properties props) {
122122
}
123123
props.put(fipsProviderKey, fipsProviderValue);
124124
}
125+
// Add other security properties
126+
String keystoreTypeValue = (String) props.get("fips.keystore.type");
127+
if (keystoreTypeValue != null) {
128+
String nonFipsKeystoreType = props.getProperty("keystore.type");
129+
props.put("keystore.type", keystoreTypeValue);
130+
if (keystoreTypeValue.equals("PKCS11")) {
131+
// If keystore.type is PKCS11, javax.net.ssl.keyStore
132+
// must be "NONE". See JDK-8238264.
133+
System.setProperty("javax.net.ssl.keyStore", "NONE");
134+
}
135+
if (System.getProperty("javax.net.ssl.trustStoreType") == null) {
136+
// If no trustStoreType has been set, use the
137+
// previous keystore.type under FIPS mode. In
138+
// a default configuration, the Trust Store will
139+
// be 'cacerts' (JKS type).
140+
System.setProperty("javax.net.ssl.trustStoreType",
141+
nonFipsKeystoreType);
142+
}
143+
if (sdebug != null) {
144+
sdebug.println("FIPS mode default keystore.type = " +
145+
keystoreTypeValue);
146+
sdebug.println("FIPS mode javax.net.ssl.keyStore = " +
147+
System.getProperty("javax.net.ssl.keyStore", ""));
148+
sdebug.println("FIPS mode javax.net.ssl.trustStoreType = " +
149+
System.getProperty("javax.net.ssl.trustStoreType", ""));
150+
}
151+
}
125152
loadedProps = true;
126153
}
127154
} catch (Exception e) {

src/java.base/share/conf/security/java.security

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,11 @@ policy.ignoreIdentityScope=false
306306
#
307307
keystore.type=pkcs12
308308

309+
#
310+
# Default keystore type used when global crypto-policies are set to FIPS.
311+
#
312+
fips.keystore.type=PKCS11
313+
309314
#
310315
# Controls compatibility mode for JKS and PKCS12 keystore types.
311316
#

0 commit comments

Comments
 (0)