如何将客户端pkcs12证书添加到Postman Chrome,W7?
2022-09-04 02:09:46
我尝试测试一个“奇怪的”GET请求,我必须提供BASIC身份验证和客户端证书。
我尝试使用Postman Chrome进行检查,但我不知道如何将证书从Chrome个人证书链接到我的请求。
我看到了这个讨论:https://github.com/a85/POSTMan-Chrome-Extension/issues/482 但它是关于MAC密钥库的,我不能转置是W7 / Chrome。
这是我的java代码设置,应该做与邮递员相同的工作,以帮助您了解我希望邮递员做什么。我们用那篇文章来写它
InputStream is = context.getResources().getAssets().open("CertificateFile.p12");
KeyStore keyStore = KeyStore.getInstance("PKCS12");
BufferedInputStream bis = new BufferedInputStream(is);
String password ="xxxxx";
keyStore.load(bis, password.toCharArray()); // password is the PKCS#12 password. If there is no password, just pass null
// Init SSL Context
KeyManagerFactory kmf = KeyManagerFactory.getInstance("X509");
kmf.init(keyStore, password.toCharArray());
KeyManager[] keyManagers = kmf.getKeyManagers();
SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(keyManagers, null, null);
HttpsURLConnection urlConnection = null;
String strURL = "theUrlITryToHit";
url = new URL(strURL);
urlConnection = (HttpsURLConnection) url.openConnection();
if(urlConnection instanceof HttpsURLConnection) {
((HttpsURLConnection)urlConnection)
.setSSLSocketFactory(sslContext.getSocketFactory());
}
urlConnection.setRequestMethod("GET");
String basicAuth = "Basic " + Base64.encodeToString("pseudo:password".getBytes(), Base64.NO_WRAP);
urlConnection.setRequestProperty ("Authorization", basicAuth);