Last week, encountered the encrypted video can not play the problem, check the log found the following error:
caused By:javax.net.ssl.SSLHandshakeException:java.security.cert.CertPathValidatorException:Trust anchor for Certification path not found.
caused By:javax.net.ssl.SSLHandshakeException:java.security.cert.CertPathValidatorException:Trust anchor for Certification path not found.
caused By:java.security.cert.CertificateException:java.security.cert.CertPathValidatorException:Trust anchor for Certification path not found.
caused By:java.security.cert.CertificateException:java.security.cert.CertPathValidatorException:Trust anchor for Certification path not found.
The final reason, should be the HTTPS site SSL digital certificate error, resulting in a network connection cannot be established, unable to download the decrypted file, you will not be able to play encrypted video.
The workaround is nothing more than two:
1, maintain the original design, that is, update the certificate.
2, the certificate is not active in the case, it can only be through the code to ignore the certificate, directly establish a connection.
The key code is as follows:
Public Static voidtrustallhosts () {//Create A trust manager that does not validate certificate chains//Android use X509 certtrustmanager[] Trustallcerts =NewTrustmanager[] {NewX509trustmanager () { Publicjava.security.cert.x509certificate[] Getacceptedissuers () {return Newjava.security.cert.x509certificate[] {}; } Public voidcheckclienttrusted (x509certificate[] chain, String authtype)throwscertificateexception {} Public voidcheckservertrusted (x509certificate[] chain, String authtype)throwscertificateexception {}}}; //Install the All-trusting trust manager Try{Sslcontext sc= Sslcontext.getinstance ("TLS"); Sc.init (NULL, Trustallcerts,Newjava.security.SecureRandom ()); Httpsurlconnection. Setdefaultsslsocketfactory (Sc.getsocketfactory ()); } Catch(Exception e) {e.printstacktrace (); } }
About HTTPS and SSL that are encountered at work