如何使用证书来命中网址,不能抛出异常。必须包括证书。给我一些演示示例。我能够阅读证书,但如何使用此证书点击网址。
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.net.HttpURLConnection;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
public class httpcert {
public static void main(String[] args) {
FileInputStream is;
try {
is = new FileInputStream("/home/devel-p/Android/PKI/CA.crt");
CertificateFactory x509CertFact = CertificateFactory.getInstance("X.509");
X509Certificate cert = (X509Certificate)x509CertFact.generateCertificate(is);
System.out.println(cert);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (CertificateException e) {
e.printStackTrace();
}
}
答案 0 :(得分:0)
SSL连接仅在服务器请求时才发送客户端证书,并且证书仅在服务器决定时才是必需的。您无法从客户端控制任何此类内容。