gpt4 book ai didi

ssl - 连接建立错误:net::ERR_SSL_VERSION_OR_CIPHER_MISMATCH

转载 作者:太空宇宙 更新时间:2023-11-03 14:57:25 28 4
gpt4 key购买 nike

我已按照 Digicert 在以下链接中提供的说明在服务器上安装了 SSL/TLS 证书。 https://www.digicert.com/ssl-certificate-installation-java.htm

还定义了 TrustManager,但我仍然无法建立安全连接。我收到连接失败错误,原因是“连接建立时出错:net::ERR_SSL_VERSION_OR_CIPHER_MISMATCH”

下面是我添加 SSL 支持的代码。

private static void addSSLSupport(DefaultIoFilterChainBuilder chain)
throws Exception {
try {
KeyStore keyStore=KeyStore.getInstance("JKS");
char[] passphrase= {'t','e','s','t','s','s','l'};
keyStore.load(new FileInputStream("/home/ec2-user/digicert/mydomain.jks"),passphrase);
Util.logInfo("Key Store loaded");
SSLContext ctx=SSLContext.getInstance("TLS");
TrustManagerFactory trustFactory=TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
trustFactory.init(keyStore);
X509TrustManager defaultTrustManager = (X509TrustManager) trustFactory.getTrustManagers()[0];
ctx.init(null, trustFactory.getTrustManagers(), null);
SslFilter sslFilter = new SslFilter(ctx);
chain.addLast("sslFilter", sslFilter);
Util.logInfo("SSL ON");
}catch(Exception e){
Util.logError(e.toString());
throw e;
}
}

最佳答案

我在初始化 SSLContext 时使用 KeyManager 而不是 TrustManager 使它工作。以下是供您引用的代码。

private static void addSSLSupport(DefaultIoFilterChainBuilder chain)
throws Exception {
try {
KeyStore keyStore=KeyStore.getInstance("JKS");
char[] passphrase= {'t','e','s','t','s','s','l'};
keyStore.load(new FileInputStream("/root/mydomain.jks"),passphrase);
Util.logInfo("Key Store loaded");
KeyManagerFactory kmf = KeyManagerFactory
.getInstance(KEY_MANAGER_FACTORY_ALGORITHM);
kmf.init(keyStore, passphrase);
SSLContext ctx=SSLContext.getInstance("TLS");
ctx.init(kmf.getKeyManagers(), null, null);
SslFilter sslFilter = new SslFilter(ctx);
chain.addLast("sslFilter", sslFilter);
Util.logInfo("SSL ON");
}catch(Exception e){
Util.logError(e.toString());
throw e;
}
}

关于ssl - 连接建立错误:net::ERR_SSL_VERSION_OR_CIPHER_MISMATCH,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27614267/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com