My HSM (Hardware Security Module) stores (or allows to use) private key, however, it does not support PKCS#11 and similar method. In turn, Apache Tomcat might work with certificate and keys either via JKS, PKCS#11 or programmatically. My goal is to enable HTTPS support on a Web server, but I see no way how to achieve that with changes in configuration files only.
I imagine an option that I could store certificate in JKS, and get private key associated with it via HSM vendor provided API. For that purpose, if I am right, I will need to re-implement JSSEImplementation and corresponding factories. As well, I will need to implement specific Key and Trust Managers.
Is that the only way to solve such problem?
Is it safe to replace JSSEImplementation in a running standalone instance of Apache Tomcat, for instance, right after it started.
Finally, I came up only to the solution below based on this example. I add
<Connector>
instance to the Tomcat configuration withsslImplementationName
property pointing to the customJSSEImplementation
class name, and extendJSSEImplementation
with customJSSESocketFactory
andX509KeyManager
classes.Tomcat configuration looks like:
CustomJSSEImplementation
class is:CustomSslContextSocketFactory
class is:CustomSslContext
interface is:HsmKeyManagerImpl
which reference private key in the HSM by ankeyAlias
property looks like:I didn't show the code how to obtain certificate which corresponds to the private, but the same alias defined by the
keyAlias
property of the<Connector>
is used to get it from the JKS.