gpt4 book ai didi

java.security.InvalidKeyException : PBES2 AlgorithmParameters not available

转载 作者:太空宇宙 更新时间:2023-11-03 12:55:18 32 4
gpt4 key购买 nike

尝试在客户端和服务器之间进行 TLS 握手。但是,更改密码规范步骤失败。同样在客户端收到如下所述的异常:我无法理解为什么我会收到如下奇怪的异常。

这是什么意思?关于如何解决此问题的任何想法?

我在 Java 7 下运行它。

java.security.NoSuchAlgorithmException: PBES2 AlgorithmParameters not available at sun.security.jca.GetInstance.getInstance(GetInstance.java:159) at java.security.Security.getImpl(Security.java:695) at java.security.AlgorithmParameters.getInstance(AlgorithmParameters.java:146) at com.certicom.security.pkcs.pkcs5.g.(Unknown Source) at com.certicom.security.pkcs.pkcs5.i.a(Unknown Source) at com.certicom.security.sslplus.b.a(Unknown Source) at com.certicom.security.cert.internal.x509.PKCS8.decrypt(Unknown Source) at com.certicom.security.cert.internal.x509.SSLPlusSupport.getLocalIdentity(Unknown Source) at com.certicom.tls.cert.CertLoader.loadLocalIdentity(Unknown Source) at com.certicom.tls.interfaceimpl.i.a(Unknown Source) at com.certicom.tls.TLSContext.loadLocalIdentity(Unknown Source) at com.onstar.emxp.util.TLSClient.loadCert(TLSClient.java:66) at com.onstar.adc.pd.connection.TLSContextLoader.getTLSContext(TLSContextLoader.java:27) at com.onstar.adc.pd.PacketClient.run(PacketClient.java:74)

java.security.InvalidKeyException: PBES2 AlgorithmParameters not available at com.certicom.security.pkcs.pkcs5.g.(Unknown Source) at com.certicom.security.pkcs.pkcs5.i.a(Unknown Source) at com.certicom.security.sslplus.b.a(Unknown Source) at com.certicom.security.cert.internal.x509.PKCS8.decrypt(Unknown Source) at com.certicom.security.cert.internal.x509.SSLPlusSupport.getLocalIdentity(Unknown Source) at com.certicom.tls.cert.CertLoader.loadLocalIdentity(Unknown Source) at com.certicom.tls.interfaceimpl.i.a(Unknown Source) at com.certicom.tls.TLSContext.loadLocalIdentity(Unknown Source) at com.onstar.emxp.util.TLSClient.loadCert(TLSClient.java:66) at com.onstar.adc.pd.connection.TLSContextLoader.getTLSContext(TLSContextLoader.java:27) at com.onstar.adc.pd.PacketClient.run(PacketClient.java:74)

java.security.KeyManagementException at com.certicom.security.cert.internal.x509.SSLPlusSupport.getLocalIdentity(Unknown Source) at com.certicom.tls.cert.CertLoader.loadLocalIdentity(Unknown Source) at com.certicom.tls.interfaceimpl.i.a(Unknown Source) at com.certicom.tls.TLSContext.loadLocalIdentity(Unknown Source) at com.onstar.emxp.util.TLSClient.loadCert(TLSClient.java:66) at com.onstar.adc.pd.connection.TLSContextLoader.getTLSContext(TLSContextLoader.java:27) at com.onstar.adc.pd.PacketClient.run(PacketClient.java:74) WARNING: Could not load certificate packetserver java.security.KeyManagementException

执行 tls 握手的客户端代码:

    socket = new Socket(host, port);
InputSSLIOStream inputStream = new InputSSLIOStream(
socket.getInputStream());
OutputSSLIOStream outputStream = new OutputSSLIOStream(
socket.getOutputStream());
TLSConnection tlsConnection = tlsContextLoader.getTLSContext()
.getClientConnection(inputStream, outputStream, "server");
tlsConnection.startHandshake();
socket.setSoTimeout(30000);
OutputStream tlsOutputStream = tlsConnection.getOutputStream();
InputStream tlsInputStream = tlsConnection.getInputStream();

我的 TLS 上下文加载器:

public class TLSContextLoader
{
public TLSContext getTLSContext()
throws Exception
{
TLSContext localTLSContext = new TLSContext();
localTLSContext.setIsStrongCipherSuiteLimited(false);
localTLSContext.setHelloProtocol("TLS1-ONLY");
localTLSContext.setEllipticCurves(new String[] { "secp256r1" });
localTLSContext.setClientAuthModes(new String[] { "ECDSA_SIGN" });
localTLSContext.setDebugFlag();
localTLSContext.setEccDraftCompatibility(-1);
localTLSContext.setX509BasicConstraintBug(true);
TLSClient.loadCert(localTLSContext, "packetserver");
localTLSContext.setPSKParam(new byte[] { 49 });
localTLSContext.loadTrustedCertificates(KeyLoader.getTrustedStream("rootca"));

localTLSContext.setRNG(new SecureRandom(generateSeed()));
LocalTrustManager localLocalTrustManager = new LocalTrustManager();
localTLSContext.setTrustManager(localLocalTrustManager);
localTLSContext.setEnabledCipherSuites(EMXPArrays.csvToArray("TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA"));

localTLSContext.setNeedClientAuth(false);
return localTLSContext;
}

private byte[] generateSeed() {
String str = new String();
str = str + "IDH" + System.identityHashCode(str);
Runtime localRuntime = Runtime.getRuntime();
str = str + "FM" + localRuntime.freeMemory();
str = str + "CT" + System.currentTimeMillis();
Properties localProperties = System.getProperties();
Enumeration localEnumeration = localProperties.elements();
while (localEnumeration.hasMoreElements()) {
str = str + localEnumeration.nextElement();
}
str = str + "VHC" + str.hashCode();
return str.getBytes();
}
}

最佳答案

以上问题已解决。为了安全起见,在客户端使用 certicom 库,在服务器端使用 JDK 7。当客户端和服务器都基于 JDK 7 安全库时,客户端能够与服务器对话并协商握手。

关于java.security.InvalidKeyException : PBES2 AlgorithmParameters not available,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21762991/

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