Changeset 12241 in josm


Ignore:
Timestamp:
2017-05-23T18:31:31+02:00 (3 years ago)
Author:
Don-vip
Message:

see #11924, see #14649 - java 9 does not seem to include Dutch certificates yet, load them from /usr/share/ca-certificates/mozilla (see Debian ca-certificates package)

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/CertificateAmendment.java

    r11944 r12241  
    4949    public static class CertAmend {
    5050        private final String id;
     51        private final String filename;
    5152        private final String sha256;
    5253
    53         CertAmend(String path, String sha256) {
    54             this.id = path;
     54        CertAmend(String id, String filename, String sha256) {
     55            this.id = id;
     56            this.filename = filename;
    5557            this.sha256 = sha256;
    5658        }
     
    6264        public final String getId() {
    6365            return id;
     66        }
     67
     68        /**
     69         * Returns the certificate filename.
     70         * @return filename for both JOSM embedded certificate and platform certificate
     71         * @since 12241
     72         */
     73        public final String getFilename() {
     74            return filename;
    6475        }
    6576
     
    7788     */
    7889    private static final CertAmend[] CERT_AMEND = {
    79         new CertAmend("resource://data/security/DST_Root_CA_X3.pem",
     90        new CertAmend("resource://data/security/DST_Root_CA_X3.pem", "DST_Root_CA_X3.pem",
    8091                "0687260331a72403d909f105e69bcf0d32e1bd2493ffc6d9206d11bcd6770739")
    8192    };
     
    8697     */
    8798    private static final CertAmend[] PLATFORM_CERT_AMEND = {
    88         new CertAmend("Staat der Nederlanden Root CA - G2",
     99        new CertAmend("Staat der Nederlanden Root CA - G2", "Staat_der_Nederlanden_Root_CA_-_G2.crt",
    89100                "668c83947da63b724bece1743c31a0e6aed0db8ec5b31be377bb784f91b6716f"),
    90         new CertAmend("Government of Netherlands G3",
     101        new CertAmend("Government of Netherlands G3", "Staat_der_Nederlanden_Root_CA_-_G3.crt",
    91102                "3c4fb0b95ab8b30032f432b86f535fe172c185d0fd39865837cf36187fa6f428")
    92103    };
  • trunk/src/org/openstreetmap/josm/tools/PlatformHookUnixoid.java

    r12239 r12241  
    88import java.io.BufferedReader;
    99import java.io.File;
     10import java.io.FileInputStream;
    1011import java.io.IOException;
    1112import java.net.URI;
     
    1516import java.nio.file.Path;
    1617import java.nio.file.Paths;
     18import java.security.KeyStoreException;
     19import java.security.NoSuchAlgorithmException;
     20import java.security.cert.CertificateException;
     21import java.security.cert.CertificateFactory;
     22import java.security.cert.X509Certificate;
    1723import java.util.Arrays;
    1824import java.util.List;
     
    2026
    2127import org.openstreetmap.josm.Main;
     28import org.openstreetmap.josm.io.CertificateAmendment.CertAmend;
    2229
    2330/**
     
    418425        return Arrays.asList(new File("/usr/local/share/proj"), new File("/usr/share/proj"));
    419426    }
     427
     428    @Override
     429    public X509Certificate getX509Certificate(CertAmend certAmend)
     430            throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException {
     431        File f = new File("/usr/share/ca-certificates/mozilla", certAmend.getFilename());
     432        if (f.exists()) {
     433            CertificateFactory fact = CertificateFactory.getInstance("X.509");
     434            try (FileInputStream is = new FileInputStream(f)) {
     435                return (X509Certificate) fact.generateCertificate(is);
     436            }
     437        }
     438        return null;
     439    }
    420440}
Note: See TracChangeset for help on using the changeset viewer.