我正在尝试使用HTTPS实现Android↔Apache通信,但我收到以下错误.我间歇性地遇到问题,大约30%的时间.
Run Code Online (Sandbox Code Playgroud)javax.net.ssl.sslPeerUnverifiedException: No peer certificate
我在网上搜索,但任何答案都帮助了我......
这是我的Android代码:
http_post = new HttpPost(Utils.IP_ADDRESS);
http_post_data = new ArrayList<NameValuePair>();
http_post_data.add(new BasicNameValuePair("regId", regid));
http_post_data.add(new BasicNameValuePair("email", globals.userInfo.mail));
http_post_data.add(new BasicNameValuePair("pass", globals.userInfo.pass));
http_post.setEntity(new UrlEncodedFormEntity(http_post_data));
HttpParams httpParameters = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(httpParameters, Utils.TIMEOUT_CONNECTION);
HttpConnectionParams.setSoTimeout(httpParameters, Utils.TIMEOUT_SOCKET);
http_client = new DefaultHttpClient(httpParameters);
response = http_client.execute(http_post);
String responseBody = EntityUtils.toString(response.getEntity(), GlobalsSingleton.applicationCharset);
Run Code Online (Sandbox Code Playgroud)
我有GoDaddy证书.那么我需要更改我的服务器或Android代码才能解决这个问题?
为了支持通过 Java 1.6 API 到使用 TLS 1.2 的远程主机的 HTTPS 连接,我们开发了一个基于 Bouncy Castle Libraries (v. 1.53) 的定制 TLS SocketConnection 工厂
它非常易于使用,只需:
String httpsURL = xxxxxxxxxx
URL myurl = new URL(httpsURL);
HttpsURLConnection con = (HttpsURLConnection )myurl.openConnection();
con.setSSLSocketFactory(new TSLSocketConnectionFactory());
InputStream ins = con.getInputStream();
Run Code Online (Sandbox Code Playgroud)
在测试期间,我连接了暴露在SSLabs 测试中的不同 Web 和远程主机
这在 90% 的情况下都能正常工作!但在某些情况下,我们会收到令人讨厌的错误:“内部 TLS 错误,这可能是一次攻击”。已经检查没有攻击。这是基于内部 BouncyCastle 异常处理的常见错误。我正在尝试为那些运气不佳的远程主机找到一个通用模式。
更新:
更新一些代码以获取额外信息,我们得到:
org.bouncycastle.crypto.tls.TlsFatalAlert: illegal_parameter(47)
at org.bouncycastle.crypto.tls.AbstractTlsClient.checkForUnexpectedServerExtension(AbstractTlsClient.java:56)
at org.bouncycastle.crypto.tls.AbstractTlsClient.processServerExtensions(AbstractTlsClient.java:207)
at org.bouncycastle.crypto.tls.TlsClientProtocol.receiveServerHelloMessage(TlsClientProtocol.java:773)
Run Code Online (Sandbox Code Playgroud)
我得到的扩展类型是这样的:
扩展类型:11 扩展数据:
根据 ExtensionType 类,“ec_point_formats”。这会导致“UnexpectedServerExtension”-->“UnexpectedServerExtension”导致--> TlsFatalAlert:非法参数,最后这是一个“内部TLS错误,这可能是一次攻击”
任何建议记录或跟踪这个奇怪的 TLS 错误....???? 正如我所说,这段代码可以工作 90%...但是对于一些远程主机,我得到了这个错误
诀窍在于覆盖 startHandShake …
注意:Java HTTPS 客户端已经多次询问了这个问题;我的问题是关于配置服务器。
我正在尝试使用MockWebServer测试我的OkHttpClient配置。我的代码访问的真正的Web服务器刚刚放弃了TLS v1.0支持,因此我将代码更改为使用TLS v1.2,并使用服务器的首选密码套件。我想用模拟真实服务器的内存中Web服务器测试此更改,但是我不知道如何SSLContext在测试中使用特定的密码套件列表配置a 。(我需要访问的所有方法在SSLContextImpl其内部类及其内部类中都得到了很好的保护。)
我已经能够找出最佳的完全包裹一的SSLServerSocketFactory,覆盖4的createServerSocket()方法,并要求setEnabledCipherSuites()在SSLServerSocket其返回,类似这样的答案与SSLSocketFactoryEx如何做客户端之前:https://开头计算器。 com / a / 23365536/278800
令人沮丧的是,使用特定的TLS版本就像调用eg这样简单SSLContext.getInstance("TLSv1.2"),但是没有类似的简单方法可以配置密码套件。
我已经用Apache 2.4和SSL启动了Windows Server.当我连接https://www.example.com并点击绿色锁定时,我有消息:
您与网站的连接是使用过时的加密技术加密的
请问有什么建议吗?
以下是ssl.conf:
#
# This is the Apache server configuration file providing SSL support.
# It contains the configuration directives to instruct the server how to
# serve pages over an https connection. For detailed information about these
# directives see <URL:http://httpd.apache.org/docs/2.4/mod/mod_ssl.html>
#
# Do NOT simply read the instructions in here without understanding
# what they do. They're here only as hints or reminders. If you are unsure
# consult the …Run Code Online (Sandbox Code Playgroud)