ssl证书 嵌入式设备,嵌入式Tomcat-更新/删除证书而无需重新启动

I am using embedded Tomcat and using SSLHostConfig to add SNI certificates when I create the connector. It works wonderfully.

I am also able to add certificates without restarting Tomcat using something like this:

SSLHostConfig sslHostConfig = new SSLHostConfig();

sslHostConfig2.setHostName(host);

sslHostConfig2.setCertificateFile(path);

connector.addSslHostConfig(sslHostConfig);

This also works perfectly.

Also, without restarting Tomcat, I can get a list of all the existing SSLHostConfig instances using this:

SSLHostConfig[] sslHostConfigs = connector.findSslHostConfigs();

However, I couldn't figure out how to update or delete an existing SSLHostConfig instance. Setting it to null in the array doesn't work. Also, replacing it in the array with a new SSLHostConfig instance doesn't work either.

Is there a way to delete or modify an SSLHostConfig instance without restarting Tomcat?

Thanks.

解决方案

To update an SSLHostConfig with a new certificate file (which was referenced when creating it originally), this works:

Http11NioProtocol protocol (Http11NioProtocol)connector.getProtocolHandler();

protocol.reloadSslHostConfig(host);

Of course this assumes that you are using the Http11NioProtocol as the protocol handler for your connector.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值