Java1.7 access Https occur SSLProtocolException and CertificateException through SSL, and download java1.7
I recently called one of the Advanced Mass Sending interfaces on the public platform:
Https://file.api.weixin.qq.com/cgi-bin/media/uploadvideo? When access_token = ACCESS_TOKEN, an exception is thrown during https access:
javax.net.ssl.SSLProtocolException: handshake alert: unrecognized_name
Keyword: unrecognized unacknowledged name.
Google, solution, code added:
//bug fiexd for: javax.net.ssl.SSLProtocolException: handshake alert: unrecognized_name System.setProperty ("jsse.enableSNIExtension", "false");
Call this interface again to throw a new exception:
javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject alternative DNS name matching file.api.weixin.qq.com found.
Continue to process. Add the following code:
URL url = new URL(requestUrl); httpUrlConn = (HttpsURLConnection)url.openConnection(); httpUrlConn.setSSLSocketFactory(ssf); //bug fixed for: java.security.cert.CertificateException: No subject alternative DNS name matching httpUrlConn.setHostnameVerifier(new CustomizedHostnameVerifier());
The CustomizedHostnameVerifier class is as follows:
import javax.net.ssl.HostnameVerifier;import javax.net.ssl.SSLSession;/** * HostnameVerifier * bug fixed :
Cause:
And then apply this class to your single SSL connection
HttpsURLConnection connection = (HttpsURLConnection) new URL ("
Https: // url "). openConnection ();
Connection. setHostnameVerifier (new CustomizedHostNameVerifier ());
Or apply to all SLL connection
HttpsURLConnection. setDefaultHostnameVerifier (new CustomizedHostnameVerifier ());
However this method might pose a security risk because basically we don't verify the hostname anymore. The server may use other website's certificate and the program will still accept it.
In short:
Because this interface is not authenticated, https is not secure, and all the code needs to be dont verify.
Refer:
Http://iteches.com/archives/45015
Http://stackoverflow.com/questions/7615645/ssl-handshake-alert-unrecognized-name-error-since-upgrade-to-java-1-7-0
When you configure the android SDK in eclipse 37, Fetching https: // dl-sslgooglecom/and appears.
This problem seems to be caused by a wall.
Now you can download the sdk-r18 sdk, can be downloaded normally, if you still can not download, you can contact me, I will send you a copy