验证JAVA不存在_java – 警告:找不到合适的证书 – 继续没有客户端身份验证

团队在尝试使用HTTPS完成相互握手时遇到以下问题

main, READ: TLSv1.2 Handshake, length = 30

*** CertificateRequest

Cert Types: RSA, DSS, ECDSA

Supported Signature Algorithms: SHA1withRSA, SHA1withDSA, SHA1withECDSA, SHA256withRSA, Unknown (hash:0x4, signature:0x2), SHA256withECDSA, SHA384withRSA, Unknown (hash:0x5, signature:0x2), SHA384withECDSA

Cert Authorities:

main, READ: TLSv1.2 Handshake, length = 4

*** ServerHelloDone

Warning: no suitable certificate found - continuing without client authentication

*** Certificate chain

我的JAVA课程如下

public class ClientCustomSSL {

@SuppressWarnings("deprecation")

public final static void main(String[] args) throws Exception {

// Trust own CA and all self-signed certs

final String CLIENT_KEYSTORE = "yourkeystore.jks";

final String CLIENT_TRUSTSTORE = "catruststore.jks";

final char[] KEYPASS_AND_STOREPASS_VALUE = "Hello1".toCharArray();

System.setProperty("https.protocols", "TLSv1");

//SSLContext sslcontext = SSLContexts.custom().loadKeyMaterial(keystore, keyPassword)(YK,"Hello1".toCharArray(),"Hello1".toCharArray()).loadTrustMaterial(CA, "Hello1".toCharArray(), (TrustStrategy) new TrustSelfSignedStrategy()).build();

KeyStore clientTrustStore = getStore(CLIENT_TRUSTSTORE, KEYPASS_AND_STOREPASS_VALUE);

KeyStore clientKeyStore = getStore(CLIENT_KEYSTORE, KEYPASS_AND_STOREPASS_VALUE);

SSLContext sslContext = SSLContexts.custom().loadKeyMaterial(clientKeyStore, "Hello1".toCharArray()).loadTrustMaterial(clientTrustStore,(TrustStrategy) new TrustSelfSignedStrategy()).build();

CloseableHttpClient httpclient = HttpClients.custom().setSSLContext(sslContext).build();

System.out.println("SSLCONETXT **** " + sslContext.getProvider());

try {

HttpGet httpget = new HttpGet("https://myserver:10220");

CloseableHttpResponse response = httpclient.execute(httpget);

try {

System.out.println("Inside TRY blcok");

HttpEntity entity = response.getEntity();

System.out.println("----------------------------------------");

System.out.println(response.getStatusLine());

EntityUtils.consume(entity);

} catch (Exception e) {

e.getMessage();

e.printStackTrace();

}

finally {

response.close();

}

} finally {

httpclient.close();

}

}

public static KeyStore getStore(final String storeFileName, final char[] password) throws KeyStoreException, IOException, CertificateException, NoSuchAlgorithmException

{

final String JAVA_KEYSTORE = "jks";

final KeyStore store = KeyStore.getInstance(JAVA_KEYSTORE);

URL url = ClientCustomSSL.class.getClassLoader().getResource(storeFileName);

String workingDir = System.getProperty("user.dir");

System.out.println("Current working directory : " + workingDir);

System.out.println("Value of URL *** " + url);

InputStream inputStream = url.openStream();

try {

store.load(inputStream, password);

} finally {

inputStream.close();

}

return store;

}

}

我正在准备一个jar文件并在UNIX框中测试它

使用以下命令

java -Djavax.net.debug = ssl -cp snSSLclientTrustWithStoreCCC.jar cassandra.cass.ClientCustomSSL

我不确定我在这里缺少什么.任何帮助将不胜感激

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值