Permalink
Browse files

Added SHA-1 checksum to acceptKeyDialog

  • Loading branch information...
dnet committed Apr 4, 2011
1 parent 467b623 commit dcf5d150a618b6b9b78b42d38943fca47cdc461b
Showing with 19 additions and 0 deletions.
  1. +19 −0 src/com/fsck/k9/activity/setup/AccountSetupCheckSettings.java
@@ -23,9 +23,13 @@
import com.fsck.k9.mail.Transport;
import com.fsck.k9.mail.store.TrustManagerFactory;
import com.fsck.k9.mail.store.WebDavStore;
import com.fsck.k9.mail.filter.Hex;

import java.security.cert.CertificateException;
import java.security.cert.CertificateEncodingException;
import java.security.cert.X509Certificate;
import java.security.NoSuchAlgorithmException;
import java.security.MessageDigest;

/**
* Checks the given settings to make sure that they can be used to send and
@@ -237,11 +241,26 @@ public void run() {

mProgressBar.setIndeterminate(false);
StringBuffer chainInfo = new StringBuffer(100);
MessageDigest sha1 = null;
try {
sha1 = MessageDigest.getInstance("SHA-1");
} catch (NoSuchAlgorithmException e) {
Log.e(K9.LOG_TAG, "Error while initializing MessageDigest", e);
}
for (int i = 0; i < chain.length; i++) {
// display certificate chain information
chainInfo.append("Certificate chain[" + i + "]:\n");
chainInfo.append("Subject: " + chain[i].getSubjectDN().toString() + "\n");
chainInfo.append("Issuer: " + chain[i].getIssuerDN().toString() + "\n");
if (sha1 != null) {
sha1.reset();
try {
char[] sha1sum = Hex.encodeHex(sha1.digest(chain[i].getEncoded()));
chainInfo.append("Fingerprint (SHA-1): " + new String(sha1sum) + "\n");
} catch (CertificateEncodingException e) {
Log.e(K9.LOG_TAG, "Error while encoding certificate", e);
}
}
}

new AlertDialog.Builder(AccountSetupCheckSettings.this)

0 comments on commit dcf5d15

Please sign in to comment.