jedisConnectionFactory setUseSsl方法过期 替换方案是什么
时间: 2024-02-03 09:13:45 浏览: 27
在Jedis 3.0版本中,`setUseSsl`方法已经被标记为过时方法,建议使用新的方法`setSslParameters`代替。
`setSslParameters`方法需要传入一个`SSLParameters`对象,可以通过以下代码创建:
```java
SSLParameters sslParameters = new SSLParameters();
sslParameters.setEndpointIdentificationAlgorithm("HTTPS");
```
然后将`SSLParameters`对象传入`jedisConnectionFactory.setSslParameters()`方法中即可。
示例代码:
```java
JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory();
jedisConnectionFactory.setHostName("localhost");
jedisConnectionFactory.setPort(6379);
jedisConnectionFactory.setPassword("password");
if (useSsl) {
SSLParameters sslParameters = new SSLParameters();
sslParameters.setEndpointIdentificationAlgorithm("HTTPS");
jedisConnectionFactory.setSslParameters(sslParameters);
}
jedisConnectionFactory.afterPropertiesSet();
```
注意:`setEndpointIdentificationAlgorithm`方法的参数取决于你的SSL证书,如果证书是由CA颁发的,则通常应该使用“HTTPS”。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)