Code example for CertificateException

0
							MessageDigest md; 
							try { 
								md = MessageDigest.getInstance("SHA-1"); 
							} catch (NoSuchAlgorithmException e) { 
								sslCertError = "Could not find SHA-1 digest"; 
								throw new CertificateException(); 
							} 
							md.update(chain[0].getEncoded()); 
							byte[] digest = md.digest(); 
							BigInteger bi = new BigInteger(1, digest); 
						    String fingerprint = String.format("%0" + (digest.length << 1) + "X", bi); 
 
						    ArrayList<StringTuple> r = new ArrayList<StringTuple>(); 
						    r.add(new StringTuple("Subject", chain[0].getSubjectDN().toString())); 
						    r.add(new StringTuple("Valid from", chain[0].getNotBefore().toLocaleString())); 
						    r.add(new StringTuple("Valid to", chain[0].getNotAfter().toLocaleString())); 
						    r.add(new StringTuple("Fingerprint", fingerprint)); 
						    r.add(new StringTuple("Chain length", String.format("%d",chain.length))); 
 
						    sslCertDetails = r; 
							sslCertFingerprint = fingerprint;