栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

HSM与Apache Tomcat一起用于HTTPS

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

HSM与Apache Tomcat一起用于HTTPS

最后,基于此示例,我仅提出以下解决方案。我将

<Connector>
实例添加到Tomcat配置中,并带有
sslImplementationName
指向自定义
JSSEImplementation
类名称的属性,并
JSSEImplementation
通过自定义
JSSESocketFactory
X509KeyManager
类进行扩展。

Tomcat配置如下所示:

<Connector       protocol="org.apache.coyote.http11.Http11Protocol"       port="8443" maxThreads="200"       scheme="https" secure="true" SSLEnabled="true"       clientAuth="true" sslProtocol="TLS" SSLEnabled="true"       sslImplementationName="x.y.z.CustomJSSEImplementation"       keyAlias="alias_of_key_in_HSM_and_cert_in_JKS"/>

CustomJSSEImplementation
类是:

public class CustomJSSEImplementation extends JSSEImplementation {   @Override   public ServerSocketFactory getServerSocketFactory(AbstractEndpoint endpoint) {      return new CustomSslContextSocketFactory(endpoint);   }   @Override   public SSLUtil getSSLUtil(AbstractEndpoint endpoint) {      return new CustomSslContextSocketFactory(endpoint);   }}

CustomSslContextSocketFactory
类是:

public class CustomSslContextSocketFactory extends JSSESocketFactory {    public static final AtomicReference<CustomSslContext> customSslContext =        new AtomicReference<CustomSslContext>();    public CustomSslContextSocketFactory(AbstractEndpoint endpoint) {        super(endpoint);    }    @Override    public KeyManager[] getKeyManagers() throws Exception {        return (customSslContext.get() == null ? super.getKeyManagers() : customSslContext.get().getKeyManagers(this));    }}

CustomSslContext
界面是:

interface CustomSslContext {    KeyManager[] getKeyManagers(JSSESocketFactory factory) throws Exception;}

HsmKeyManagerImpl
通过
keyAlias
属性在HSM中引用私钥的形式如下:

public class HsmKeyManagerImpl implements X509KeyManager {    ...    @Override    public PrivateKey getPrivateKey(String alias) {        // HSM Vendor specific API calls    }}

我没有显示代码如何获取与私有证书相对应的证书,但是使用的

keyAlias
属性定义的相同别名
<Connector>
用于从JKS 获取证书。



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/435777.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号