I found if I turn on fips mode, the JRE only allow SunJSSE TrustManagers and KeyManagers when you create a SSLContext to do SSL handshake. I google the source code of sun.security.ssl.SSLContextImpl, and found the following code:
in chooseTrustManager(TrustManager[] tm) function:
if (tm[i] instanceof X509TrustManager) {
if (SunJSSE.isFIPS() && !(tm[i] instanceof X509TrustManagerImpl)) {
throw new KeyManagementException
("FIPS mode: only SunJSSE TrustManagers may be used");
}
}
in chooseKeyManager(KeyManager[] kms) function:
if ((km instanceof X509KeyManagerImpl) || (km instanceof SunX509KeyManagerImpl)) {
return (X509ExtendedKeyManager)km;
} else {
// throw exception, we don't want to silently use the
// dummy keymanager without telling the user.
throw new KeyManagementException
("FIPS mode: only SunJSSE KeyManagers may be used");
}
like the above code shows, the trustmanger must be instance of X509TrustManagerImpl class, and this class is final, so it could not be extended.
But I want to do additional check to the subject of certificate when doing SSL handshake, so I use a customized trust manager which extends X509TrustManager class to do additional check in checkServerTrusted() and checkClientTrusted() function. But it results in the exception "FIPS mode: only SunJSSE TrustManagers may be used" when turn on fips mode.
Although I know forcing user to SunJSSE TrustManagers is for FIPS mode requirement, but I'm curious if there is any other way to fulfill my requirement to do the additional check if I can't use customized trustmanagerr or keymanger?