如果您对如何解决javax.net.ssl.SSLHandshakeException错误?感兴趣,那么本文将是一篇不错的选择,我们将为您详在本文中,您将会了解到关于如何解决javax.net.ssl
如果您对如何解决javax.net.ssl.SSLHandshakeException错误?感兴趣,那么本文将是一篇不错的选择,我们将为您详在本文中,您将会了解到关于如何解决javax.net.ssl.SSLHandshakeException错误?的详细内容,我们还将为您解答java.net.ssl.sslhandshake怎么办的相关问题,并且为您提供关于3、javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake 错误、Android 11的javax.net.ssl.SSLHandshakeException、java 使用post或者get请求出现 javax.net.ssl.SSLHandshakeException、javapns 推送IOS报javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake的有价值信息。
本文目录一览:- 如何解决javax.net.ssl.SSLHandshakeException错误?(java.net.ssl.sslhandshake怎么办)
- 3、javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake 错误
- Android 11的javax.net.ssl.SSLHandshakeException
- java 使用post或者get请求出现 javax.net.ssl.SSLHandshakeException
- javapns 推送IOS报javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
如何解决javax.net.ssl.SSLHandshakeException错误?(java.net.ssl.sslhandshake怎么办)
我连接了VPN,以设置广告资源API来获取产品列表,并且效果很好。一旦我从Web服务获得结果并绑定到UI。当我遇到付款错误时,我也将PayPal与我的make Express结帐应用程序集成在一起。我将servlet用于后端过程。谁能说出解决此问题的方法?
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException:unable to find valid certification path to requested target
答案1
小编典典首先,你需要从尝试连接的服务器获取公共证书。这可以通过多种方式完成,例如联系服务器管理员并提出要求,使用OpenSSL下载它,或者,由于这似乎是HTTP服务器,因此可以通过任何浏览器连接到该服务器,并查看页面的安全信息。 ,并保存证书的副本。(Google应该能够准确告诉你如何使用特定的浏览器。)
现在你已将证书保存在文件中,你需要将其添加到JVM的信任库中。在$JAVA_HOME/jre/lib/security/JRE
或$JAVA_HOME/lib/securityJDK
的cacertsJava
中,有一个名为的文件,该文件包含著名的证书颁发机构的公共证书。要导入新证书,请以具有写cacerts权限的用户身份运行keytool:
keytool -import -file <the cert file> -alias <some meaningful name> -keystore <path to cacerts file>
它很可能会要求你输入密码。Java随附的默认密码是changeit。几乎没有人更改它。在完成了这些相对简单的步骤之后,你将安全地进行通信,并确保与正确的服务器且仅与正确的服务器通信(只要它们不会丢失私钥)。
3、javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake 错误
使用Jmeter做测试的时候,出现 javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
错误,解决方式是修改java安装路径的文件: G:\Java\jre1.8.0_201\lib\security\java.security
。把注释的 crypto.policy=unlimited
放开。
参考文档: https://blog.csdn.net/kevin_mails/article/details/82143490
http://xwiz.cn/2018-05-09-java-ssl-ciphersuite
Android 11的javax.net.ssl.SSLHandshakeException
如何解决Android 11的javax.net.ssl.SSLHandshakeException?
尝试在Android 11上使用HTTPS连接到我的服务器时,我的应用程序抛出javax.net.ssl.SSLHandshakeException错误。
可能是什么原因造成的?我正在通过CloudFlare使用完全SSL。 Android 11是否需要完整的SSL(严格)?
2020-09-12 19:21:37.131 20726-20857/? I/APP: I 09/12/2020 19:21:37:130 b7ef51e0 Net| POST request (Pull): sync.mydomain.com/rc/v1/app/login
2020-09-12 19:21:37.146 206-212/? E/android.system.suspend@1.0-service: Error opening kernel wakelock stats for: wakeup34: Permission denied
2020-09-12 19:21:37.149 206-212/? E/android.system.suspend@1.0-service: Error opening kernel wakelock stats for: wakeup35: Permission denied
2020-09-12 19:21:37.143 206-206/? W/Binder:206_2: type=1400 audit(0.0:3377): avc: denied { read } for name="wakeup34" dev="sysfs" ino=18474 scontext=u:r:system_suspend:s0 tcontext=u:object_r:sysfs:s0 tclass=dir permissive=0
2020-09-12 19:21:37.147 206-206/? W/Binder:206_2: type=1400 audit(0.0:3378): avc: denied { read } for name="wakeup35" dev="sysfs" ino=18534 scontext=u:r:system_suspend:s0 tcontext=u:object_r:sysfs:s0 tclass=dir permissive=0
2020-09-12 19:21:37.192 20726-20857/? I/APP: I 09/12/2020 19:21:37:192 b7ef51e0 SSLImplJava| SSL connect to sync.mydomain.com:443
2020-09-12 19:21:37.192 20726-20857/? I/APP: I 09/12/2020 19:21:37:192 b7ef51e0 SSLImplJava| Creating secure SSL factory
2020-09-12 19:21:37.193 20726-20857/? I/APP: I 09/12/2020 19:21:37:193 b7ef51e0 SSLImplJava| Creating TrustManager for system certificates
2020-09-12 19:21:37.193 20726-20857/? I/APP: I 09/12/2020 19:21:37:193 b7ef51e0 SSLImplJava| Loading all SSL certificates from config
2020-09-12 19:21:37.193 20726-20857/? I/APP: I 09/12/2020 19:21:37:193 b7ef51e0 SSLImplJava| SSL certificates loaded: 0
2020-09-12 19:21:37.193 20726-20857/? I/APP: I 09/12/2020 19:21:37:193 b7ef51e0 SSLImplJava| Creating TrustManager for custom certificates
2020-09-12 19:21:37.193 20726-20857/? I/APP: I 09/12/2020 19:21:37:193 b7ef51e0 SSLImplJava| clientSSLCertificate is
2020-09-12 19:21:37.195 20726-20857/? I/APP: I 09/12/2020 19:21:37:195 b7ef51e0 SSLImplJava| Secure SSL factory initialization completed
2020-09-12 19:21:37.196 20726-20857/? I/APP: E 09/12/2020 19:21:37:196 b7ef51e0 SSLImplJava| Call of "connect" Failed: SSLHandshakeException: Attempt to invoke virtual method ''void java.io.OutputStream.write(byte[],int,int)'' on a null object reference
2020-09-12 19:21:37.197 20726-20857/? W/System.err: javax.net.ssl.SSLHandshakeException: Attempt to invoke virtual method ''void java.io.OutputStream.write(byte[],int)'' on a null object reference
2020-09-12 19:21:37.197 20726-20857/? W/System.err: at com.android.org.conscrypt.SSLUtils.toSSLHandshakeException(SSLUtils.java:362)
2020-09-12 19:21:37.197 20726-20857/? W/System.err: at com.android.org.conscrypt.ConscryptEnginesocket.doHandshake(ConscryptEnginesocket.java:276)
2020-09-12 19:21:37.197 20726-20857/? W/System.err: at com.android.org.conscrypt.ConscryptEnginesocket.startHandshake(ConscryptEnginesocket.java:217)
2020-09-12 19:21:37.197 20726-20857/? W/System.err: at com.android.org.conscrypt.ConscryptEnginesocket.waitForHandshake(ConscryptEnginesocket.java:563)
2020-09-12 19:21:37.197 20726-20857/? W/System.err: at com.android.org.conscrypt.ConscryptEnginesocket.getoutputStream(ConscryptEnginesocket.java:298)
2020-09-12 19:21:37.197 20726-20857/? W/System.err: at com.rhomobile.rhodes.socket.SSLImpl.connect(SSLImpl.java:639)
2020-09-12 19:21:37.197 20726-20857/? W/System.err: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method ''void java.io.OutputStream.write(byte[],int)'' on a null object reference
2020-09-12 19:21:37.197 20726-20857/? W/System.err: at com.android.org.conscrypt.ConscryptEnginesocket$SSLOutputStream.writetoSocket(ConscryptEnginesocket.java:715)
2020-09-12 19:21:37.197 20726-20857/? W/System.err: at com.android.org.conscrypt.ConscryptEnginesocket$SSLOutputStream.writeInternal(ConscryptEnginesocket.java:689)
2020-09-12 19:21:37.197 20726-20857/? W/System.err: at com.android.org.conscrypt.ConscryptEnginesocket$SSLOutputStream.access$200(ConscryptEnginesocket.java:616)
2020-09-12 19:21:37.197 20726-20857/? W/System.err: at com.android.org.conscrypt.ConscryptEnginesocket.doHandshake(ConscryptEnginesocket.java:245)
2020-09-12 19:21:37.197 20726-20857/? W/System.err: ... 4 more
2020-09-12 19:21:37.197 20726-20857/? I/APP: E 09/12/2020 19:21:37:197 b7ef51e0 Net| Operation finished with error 35: SSL connect error
2020-09-12 19:21:37.197 20726-20857/? I/APP: E 09/12/2020 19:21:37:197 b7ef51e0 Net| CURLNetRequest: METHOD = [POST] URL = [https://sync.mydomain.com/rc/v1/app/login] BODY = [{"login":"","password":"","remember_me":1}]
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
java 使用post或者get请求出现 javax.net.ssl.SSLHandshakeException
问题描述:使用Java HttpClient 请求https接口时本地环境没有,但是部署到Linux服务器上出现报错
报错内容
open-jdk版本是1.8.0_301
在调用https接口时,出现以下错误
javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)
at sun.security.ssl.Handshaker.activate(Handshaker.java:529)
at sun.security.ssl.SSLSocketImpl.kickstartHandshake(SSLSocketImpl.java:1492)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1361)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1413)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1397)
解决办法
以下提供两种解决办法
1、修改jdk配置文件
解决办法:找到jdk 1.8安装目录,
找到 安装目录 里面的lib\security 下面有个java.security。
**找到对应的SSLv3,TLSv1, TLSv1.1, 注释掉,重启项目就好了**
linux查找jdk安装目录:
which java
ls -lrt /usr/bin/java
ls -lrt /etc/alternatives/java
2、修改HttpClient 发包器
import org.apache.http.httpentity;
import org.apache.http.ParseException;
import org.apache.http.client.methods.*;
import org.apache.http.config.Registry;
import org.apache.http.config.RegistryBuilder;
import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.TrustStrategy;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.conn.BasicHttpClientConnectionManager;
import org.apache.http.ssl.SSLContexts;
import org.apache.http.util.EntityUtils;
import javax.net.ssl.SSLContext;
import java.io.IOException;
import java.net.URI;
import java.security.KeyManagementException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
/**
* @author: dwl
* @create: 2021-06-07 10:33
**/
public class HTTPClientImpl {
final String HTTPS = "https";
final String HTTP = "http";
CloseableHttpClient httpClient;
HTTPClientData httpClientData = new HTTPClientData();
/**
* 无参构造方法,创建并初始化httpClient
*/
public HTTPClientImpl(){
TrustStrategy acceptingTrustStrategy = (cert, authType) -> true;
SSLContext sslContext = null;
try {
sslContext = SSLContexts.custom().loadTrustMaterial(null, acceptingTrustStrategy).build();
} catch (NoSuchAlgorithmException | KeyManagementException | KeyStoreException e) {
e.printstacktrace();
}
assert sslContext != null;
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext,
NoopHostnameVerifier.INSTANCE);
Registry<ConnectionSocketFactory> socketFactoryRegistry =
RegistryBuilder.<ConnectionSocketFactory> create()
.register(HTTPS, sslsf)
.register(HTTP, new PlainConnectionSocketFactory())
.build();
BasicHttpClientConnectionManager connectionManager =
new BasicHttpClientConnectionManager(socketFactoryRegistry);
// 获得Http客户端(可以理解为:你得先有一个浏览器;注意:实际上HttpClient与浏览器是不一样的)
httpClient = HttpClientBuilder.create().setSSLSocketFactory(sslsf).setConnectionManager(connectionManager).build();
}
/**
* GET请求目标URI
* @param uri 目标URI
*/
public HTTPClientData doGet(URI uri){
// 创建Get请求
HttpGet httpGet = new HttpGet(uri);
sendRequest(httpGet);
return httpClientData;
}
public HTTPClientData doPostJSON(URI uri, String jsonString){
// 创建Post请求
HttpPost httpPost = new HttpPost(uri);
StringEntity entity = new StringEntity(jsonString, "UTF-8");
// post请求是将参数放在请求体里面传过去的;这里将entity放入post请求体中
httpPost.setEntity(entity);
sendRequest(httpPost);
return httpClientData;
}
public HTTPClientData doDelete(URI uri){
// 创建Delete请求
HttpDelete httpDelete = new HttpDelete(uri);
sendRequest(httpDelete);
return httpClientData;
}
public void sendRequest(HttpRequestBase httpRequest){
// 响应模型
CloseableHttpResponse response = null;
try {
// 由客户端执行(发送)Get请求
response = httpClient.execute(httpRequest);
// 从响应模型中获取响应实体
httpentity responseEntity = response.getEntity();
httpClientData.setAllHeaders(response.getAllHeaders());
httpClientData.setStatus(response.getStatusLine());
// System.out.println("响应包头为:" + Arrays.toString(response.getAllHeaders()));
// System.out.println("响应状态为:" + response.getStatusLine());
if (responseEntity != null) {
httpClientData.setContent(EntityUtils.toString(responseEntity));
httpClientData.setContentLength(responseEntity.getContentLength());
httpClientData.setContentEncoding(responseEntity.getContentEncoding());
httpClientData.setContentType(responseEntity.getContentType());
// System.out.println("响应内容长度为:" + responseEntity.getContentLength());
// System.out.println("响应内容为:" + EntityUtils.toString(responseEntity));
}
} catch (ParseException | IOException e) {
e.printstacktrace();
} finally {
try {
// 释放资源
if (httpClient != null) {
httpClient.close();
}
if (response != null) {
response.close();
}
} catch (IOException e) {
e.printstacktrace();
}
}
}
}
import org.apache.http.Header;
import org.apache.http.StatusLine;
import java.util.Arrays;
/**
* @author: dwl
* @create: 2021-06-16 13:17
**/
public class HTTPClientData {
Header[] AllHeaders;
StatusLine Status;
long ContentLength;
Header ContentEncoding;
Header ContentType;
String Content;
public Header[] getAllHeaders() {
return AllHeaders;
}
@Override
public String toString() {
return "HTTPClientData{" +
"AllHeaders=" + Arrays.toString(AllHeaders) +
", Content='" + Content + '\'' +
'}';
}
public void setAllHeaders(Header[] allHeaders) {
AllHeaders = allHeaders;
}
public StatusLine getStatus() {
return Status;
}
public void setStatus(StatusLine status) {
Status = status;
}
public long getContentLength() {
return ContentLength;
}
public void setContentLength(long contentLength) {
ContentLength = contentLength;
}
public Header getContentEncoding() {
return ContentEncoding;
}
public void setContentEncoding(Header contentEncoding) {
ContentEncoding = contentEncoding;
}
public Header getContentType() {
return ContentType;
}
public void setContentType(Header contentType) {
ContentType = contentType;
}
public String getContent() {
return Content;
}
public void setContent(String content) {
Content = content;
}
}
javapns 推送IOS报javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
使用javapns推送IOS报SSL连接失败,是因为苹果那边禁用了SSL吗
如果禁用了 要用什么办法推送
关于如何解决javax.net.ssl.SSLHandshakeException错误?和java.net.ssl.sslhandshake怎么办的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于3、javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake 错误、Android 11的javax.net.ssl.SSLHandshakeException、java 使用post或者get请求出现 javax.net.ssl.SSLHandshakeException、javapns 推送IOS报javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake等相关知识的信息别忘了在本站进行查找喔。
本文标签: