- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试使用 HTTPClient/URLConnection 连接到 REST 网络服务。这是一段在 jdk 1.7 中运行良好但在使用 jdk1.6 时抛出 SSLHandshake 异常的简单代码
IO Exception: javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject alternative DNS name matching your.domain.name.com found.
...
Caused by: java.security.cert.CertificateException: No subject alternative DNS name matching your.domain.name.com found.
此外,代码非常基础
URL url = new URL("https://your.domain.name.com/services/");
HttpsURLConnection urlConnection = (HttpsURLConnection) url.openConnection();
urlConnection.setRequestProperty("Authorization", "Basic " + encodedCredenials);
urlConnection.setRequestProperty("Content-Type", "application/vnd.mtdomain.gold+json");
InputStream is = urlConnection.getInputStream();
这是 jdk 1.6 和 1.7 之间的已知问题吗?我们怎样才能解决这个问题?我不太了解 SSL 相关问题。
最佳答案
此问题可能由于以下原因(错误的 URL、损坏的证书或无效的证书)而发生。
要安装证书,请使用以下语法。
默认 keystore 将证书安装到默认 keystore (JDK cacerts)1.从服务器导出证书(.cer)2. 打开命令提示符并转到 JAVA_HOME/jre/lib/security3.执行以下命令
window
keytool -import -v -alias -keystore cacerts -file \.cer
Password: changeit
Unix
/bin/keytool -import -v -alias -keystore cacerts -file \.cer
Password: changeit
自定义 keystore 将证书安装到自定义 keystore 1.从服务器导出证书(.cer)2. 打开命令提示符并转到要创建自定义 keystore 的位置3.执行以下命令 window keytool -import -v -trustcacerts -alias -file\.cer -keystore .jks -keypass changeit密码:changeit
Unix/bin/keytool -import -v -trustcacerts -alias -file\.cer -keystore .jks -keypass changeit密码:changeit
在调用自定义 keystore 时添加以下系统变量
-Dweblogic.security.SSL.ignoreHostnameVerification=true -Dweblogic.security.TrustKeyStore=CustomTrust -
Dweblogic.security.CustomTrustKeyStoreFileName=<location>/<keystore-name>.jks -Djavax.net.ssl.trustStore=<location>/<keystore-name>.jks -Djavax.net.ssl.trustStorePassword=changeit
关于java - 使用 jdk 1.6 时出现 SSLHandshake 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28560406/
我正在使用 SSL 连接,对于某些用途,当它从 Java 库中抛出时,我需要找出警报类型及其严重性。 sslException.getAlertLevel() or sslException.getA
如何解决“SSLHANDSHAKE 异常”以及如何在 httpClient post 方法中维护“Cookies”。我已将一些 session 参数“nameValuePair”和 cookie 传递
svn: OPTIONS of 'https://comp20006.eng.unimelb.edu.au/svn/pochen': SSL handshake failed: Secure conn
当我尝试在 Apple Mail 中配置我的企业邮件帐户 (Exchange) 时,我可以在控制台中看到以下错误日志。但是在 Outlook 2011 邮件客户端中配置相同的帐户时我看不到此错误。当我
我有一组用 Java 编写的“包装器”服务,运行在 AWS 上的 Tomcat 8 上,它们调用客户端的一组 MIME 服务。当我尝试调用他们的服务时,我得到一个 SSLHandshakeExcept
我正在使用 iOS 应用程序,在 iOS 9 中测试时出现以下错误。 CFNetwork SSLHandshake failed (-9806) NSURLSession/NSURLConnec
我有带有 REST API 的自定义硬件设备。设备具有自签名根证书。我正在尝试进行简单的 GET 调用,但我的所有请求都失败了: CFNetwork SSLHandshake failed (-980
我用 Java 程序(使用 HttpUrlConnection)向网站发送 http 请求并从那里下载文件。 该网站是“https”并使用证书。 当我尝试运行我的代码时出现异常: cause java
有 iOS 9 beta 1 的人有这个问题吗? 我使用标准 NSURLConnection 连接到网络服务,一旦调用网络服务,我就会收到以下错误。这目前在 iOS 8.3 中工作 可能的测试错误?任
我在从 Java 发送邮件时遇到以下异常。 31/03 14:06:19:571 INFO [ ] IBSUtils sendMailfromsmtp() MessagingException in
2015-11-04 15:17:23.236 Testing[2504:80857] CFNetwork SSLHandshake failed (-9824) 2015-11-04 15:17:2
有 2 个 Websphere 服务器。第一个是客户端,第二个是服务器 (8.5.5.13)。 最终用户向客户发出 SOAP 请求。客户端接收请求,进行一些处理,然后向服务器发出REST 请求。 当服
我在我的控制台 CFNetwork SSLHandshake failed (-9806) 中收到 xCode 的错误日志。 我如何找出哪个请求导致失败的日志。 当我的应用程序启动时,有很多第三方请求
有人遇到过这个问题吗?我的应用程序工作正常,当我更新到最新的 Xcode 时,这个错误开始出现。这些是错误: CFNetwork SSLHandshake failed (-9806) NSURLSe
我正在尝试修复 CFNetwork SSLHandshake 失败 (-9806) 警告。我的应用程序运行良好,但是当我在设备中通过 Xcode 运行应用程序时,应用程序崩溃了。我在 .plist 中
使用 iOS 9 beta 1 的人遇到过这个问题吗? 我使用标准 NSURLConnection 连接到网络服务,一旦调用网络服务,我就会收到以下错误。这目前在 iOS 8.3 中有效 可能是测试版
有时我的代码中出现 CFNetwork SSLHandshake failed -(9806),但我不确定为什么会这样,因为我的代码运行顺利,除非我在 iOS 中运行它6 然后在 iOS 7 64 位
使用 iOS 9 beta 1 的人遇到过这个问题吗? 我使用标准 NSURLConnection 连接到网络服务,一旦调用网络服务,我就会收到以下错误。这目前在 iOS 8.3 中有效 可能是测试版
我正在开发 Apple Pay POC,在此过程中,我尝试使用休息服务,但很难通过 Java 代码连接到该服务器。 但是,使用下面的curl命令可以正常工作。 curl -v --cert publi
我在登录应用程序时在我的 ios 应用程序中收到 CFNetwork SSL Handshake failed(-9807)。 我的应用程序使用的是 Xcode 7.3 版。 我认为这个问题是由于 s
我是一名优秀的程序员,十分优秀!