https代理服務器(五)換電腦
1
brew install mkcert
mkcert -CAROOT
沒有
2
mkcert -install
mkcert -CAROOT
有了
3
啟動MyFiddler,手機連接,失敗
4
拷貝原key和證書至root目錄
再次mkcert -install
5 好了
6 公鑰摘要
public class PemReader {
public static X509Certificate readCertificateFromPem(String filePath) throws Exception {
try (InputStream is = new FileInputStream(filePath)) {
CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
X509Certificate certificate = (X509Certificate) certificateFactory.generateCertificate(is);
return certificate;
}
}
public static void main(String[] args) {
try {
X509Certificate cert = readCertificateFromPem("/Users/Zhuanz1/Library/Application Support/mkcert/rootCA.pem");
System.out.println("Certificate Subject: " + cert.getSubjectX500Principal());
PublicKey publicKey = cert.getPublicKey();
byte []k = publicKey.getEncoded();
System.out.println(encrypt(k));
} catch (Exception e) {
e.printStackTrace();
}
}
public static String encrypt(byte[] input) {
try {
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(input);
byte[] digest = md.digest();
StringBuilder sb = new StringBuilder();
for (byte b : digest) {
sb.append(String.format("%02x", b & 0xff));
}
return sb.toString();
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
Certificate Subject: CN=mkcert mac@macdeMacBook.local, OU=mac@macdeMacBook.local, O=mkcert development CA
Disconnected from the target VM, address: '127.0.0.1:64269', transport: 'socket'
942fb8cd5be910509faf8a39dd189240
7 在舊電腦運行6的代碼同樣結果
浙公網安備 33010602011771號