2024年6月3日发(作者:)
String p = ( == 1) ? "changeit" : args[1];
passphrase = Array();
} else {
n("Usage: java InstallCert
return;
}
File file = new File("jssecacerts");
if (() == false) {
char SEP = torchar;
File dir = new File(perty("") + SEP
+ "lib" + SEP + "security");
file = new File(dir, "jssecacerts");
if (() == false) {
file = new File(dir, "cacerts");
}
}
n("Loading KeyStore " + file + "...");
InputStream in = new FileInputStream(file);
KeyStore ks = tance(aultType());
(in, passphrase);
();
SSLContext context = tance("TLS");
TrustManagerFactory tmf =
tance(aultAlgorithm());
(ks);
X509TrustManager defaultTrustManager = (X509TrustManager) stManagers()[0];
SavingTrustManager tm = new SavingTrustManager(defaultTrustManager);
(null, new TrustManager[]{
tm
}
, null);
SSLSocketFactory factory = ketFactory();
n("Opening connection to " + host + ":" + port + "...");
SSLSocket socket = (SSLSocket) Socket(host, port);
imeout(10000);
try {
n("Starting ");
andshake();
();
n();
n("No errors, certificate is already trusted");
}
catch (SSLException e) {
n();
tackTrace();
}
X509Certificate[] chain = ;
if (chain == null) {
n("Could not obtain server certificate chain");
return;
}
BufferedReader reader =
new BufferedReader(new InputStreamReader());
n();
n("Server sent " + + " certificate(s):");
n();
MessageDigest sha1 = tance("SHA1");
MessageDigest md5 = tance("MD5");
for (int i = 0; i < ; i++) {
X509Certificate cert = chain[i];
n
(" " + (i + 1) + " Subject " + jectDN());
n(" Issuer " + uerDN());
(oded());
n(" sha1 " + toHexString(()));
(oded());
n(" md5 " + toHexString(()));
n();
}
n("Enter certificate to add to trusted keystore or 'q' to quit: [1]");
String line = ne().trim();
int k;
try {
k = (() == 0) ? 0 : nt(line) - 1;
}
catch (NumberFormatException e) {
发布评论