Cipher debugging

pull/194/merge
M66B 3 years ago
parent 778d661419
commit ebab1f0299

@ -2699,57 +2699,67 @@ public class Log {
static SpannableStringBuilder getCiphers() { static SpannableStringBuilder getCiphers() {
SpannableStringBuilder ssb = new SpannableStringBuilderEx(); SpannableStringBuilder ssb = new SpannableStringBuilderEx();
try { for (String protocol : new String[]{"SSL", "TLS"})
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); try {
tmf.init((KeyStore) null); int begin = ssb.length();
ssb.append("Protocol: ").append(protocol);
ssb.setSpan(new StyleSpan(Typeface.BOLD), begin, ssb.length(), 0);
ssb.append("\r\n\r\n");
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
tmf.init((KeyStore) null);
ssb.append("Provider: ").append(tmf.getProvider().getName()).append("\r\n"); ssb.append("Provider: ").append(tmf.getProvider().getName()).append("\r\n");
ssb.append("Algorithm: ").append(tmf.getAlgorithm()).append("\r\n"); ssb.append("Algorithm: ").append(tmf.getAlgorithm()).append("\r\n");
TrustManager[] tms = tmf.getTrustManagers(); TrustManager[] tms = tmf.getTrustManagers();
if (tms != null) if (tms != null)
for (TrustManager tm : tms) for (TrustManager tm : tms)
ssb.append("Manager: ").append(tm.getClass().getName()).append("\r\n"); ssb.append("Manager: ").append(tm.getClass().getName()).append("\r\n");
SSLContext sslContext = SSLContext.getInstance("TLS"); SSLContext sslContext = SSLContext.getInstance(protocol);
ssb.append("Context: ").append(sslContext.getProtocol()).append("\r\n\r\n"); ssb.append("Context: ").append(sslContext.getProtocol()).append("\r\n\r\n");
sslContext.init(null, tmf.getTrustManagers(), null); sslContext.init(null, tmf.getTrustManagers(), null);
SSLSocket socket = (SSLSocket) sslContext.getSocketFactory().createSocket(); SSLSocket socket = (SSLSocket) sslContext.getSocketFactory().createSocket();
List<String> protocols = new ArrayList<>(); List<String> protocols = new ArrayList<>();
protocols.addAll(Arrays.asList(socket.getEnabledProtocols())); protocols.addAll(Arrays.asList(socket.getEnabledProtocols()));
for (String p : socket.getSupportedProtocols()) { for (String p : socket.getSupportedProtocols()) {
boolean enabled = protocols.contains(p); boolean enabled = protocols.contains(p);
int start = ssb.length(); if (!enabled)
ssb.append(p); ssb.append('(');
if (!enabled) int start = ssb.length();
ssb.setSpan(new StrikethroughSpan(), start, ssb.length(), 0); ssb.append(p);
if (!enabled) {
ssb.setSpan(new StrikethroughSpan(), start, ssb.length(), 0);
ssb.append(')');
}
ssb.append("\r\n");
}
ssb.append("\r\n"); ssb.append("\r\n");
}
ssb.append("\r\n"); List<String> ciphers = new ArrayList<>();
ciphers.addAll(Arrays.asList(socket.getEnabledCipherSuites()));
List<String> ciphers = new ArrayList<>();
ciphers.addAll(Arrays.asList(socket.getEnabledCipherSuites())); for (String c : socket.getSupportedCipherSuites()) {
boolean enabled = ciphers.contains(c);
for (String c : socket.getSupportedCipherSuites()) { if (!enabled)
boolean enabled = ciphers.contains(c); ssb.append('(');
if (!enabled) int start = ssb.length();
ssb.append('('); ssb.append(c);
int start = ssb.length(); if (!enabled) {
ssb.append(c); ssb.setSpan(new StrikethroughSpan(), start, ssb.length(), 0);
if (!enabled) { ssb.append(')');
ssb.setSpan(new StrikethroughSpan(), start, ssb.length(), 0); }
ssb.append(')'); ssb.append("\r\n");
} }
ssb.append("\r\n"); ssb.append("\r\n");
} catch (Throwable ex) {
ssb.append(ex.toString());
} }
ssb.append("\r\n");
} catch (Throwable ex) {
ssb.append(ex.toString());
}
ssb.setSpan(new RelativeSizeSpan(HtmlHelper.FONT_SMALL), 0, ssb.length(), 0); ssb.setSpan(new RelativeSizeSpan(HtmlHelper.FONT_SMALL), 0, ssb.length(), 0);

Loading…
Cancel
Save