Changeset 10083 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2016-03-30T18:38:06+02:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/CertificateAmendment.java
r10079 r10083 48 48 49 49 private static final String[] SHA_HASHES = { 50 " 139a5e4a4e0fa505378c72c5f700934ce8333f4e6b1b508886c4b0eb14f4be99",51 " 916a8f9232328192968c81c8edb672fa539f726861dfe379ca722050e19962cd"50 "0687260331a72403d909f105e69bcf0d32e1bd2493ffc6d9206d11bcd6770739", 51 "c766a9bef2d4071c863a31aa4920e813b2d198608cb7b7cfe21143b836df09ea" 52 52 }; 53 53 … … 87 87 for (int i = 0; i < CERT_AMEND.length; i++) { 88 88 CachedFile certCF = new CachedFile(CERT_AMEND[i]); 89 MessageDigest md; 89 byte[] certBytes = certCF.getByteContent(); 90 ByteArrayInputStream certIS = new ByteArrayInputStream(certBytes); 91 X509Certificate cert; 92 90 93 try { 91 md = MessageDigest.getInstance("SHA-256"); 94 cert = (X509Certificate) cf.generateCertificate(certIS); 95 MessageDigest md = MessageDigest.getInstance("SHA-256"); 96 String sha1 = Utils.toHexString(md.digest(cert.getEncoded())); 97 if (!SHA_HASHES[i].equals(sha1)) { 98 throw new RuntimeException(tr("Error adding certificate {0} - certificate fingerprint mismatch. Expected {1}, was {2}", 99 CERT_AMEND[i], 100 SHA_HASHES[i], 101 sha1 102 )); 103 } 104 } catch (CertificateException ex) { 105 throw new IOException(ex); 92 106 } catch (NoSuchAlgorithmException ex) { 93 107 throw new RuntimeException(ex); 94 }95 byte[] certBytes = certCF.getByteContent();96 byte[] sha = md.digest(certBytes);97 if (!SHA_HASHES[i].equals(Utils.toHexString(sha)))98 throw new RuntimeException(tr("Error adding certificate {0} - hash mismatch. Expected {1}, was {2}",99 CERT_AMEND[i], SHA_HASHES[i], Utils.toHexString(sha)));100 101 ByteArrayInputStream certIS = new ByteArrayInputStream(certBytes);102 X509Certificate cert;103 try {104 cert = (X509Certificate) cf.generateCertificate(certIS);105 } catch (CertificateException ex) {106 throw new IOException(ex);107 108 } 108 109 if (certificateIsMissing(keyStore, cert)) {
Note:
See TracChangeset
for help on using the changeset viewer.