1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-12-24 08:38:51 -05:00

Merge branch 'master' of https://github.com/dnet/k-9 into dnet-master

* 'master' of https://github.com/dnet/k-9:
  Added SHA-1 checksum to acceptKeyDialog
This commit is contained in:
Jesse Vincent 2011-04-07 15:44:09 +10:00
commit e3818e7739

View File

@ -23,9 +23,13 @@ import com.fsck.k9.mail.Store;
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 class AccountSetupCheckSettings extends K9Activity implements OnClickList
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)