Ignore:
Timestamp:
2014-06-01T17:55:24+02:00 (9 years ago)
Author:
Don-vip
Message:

see #10033 - allow remote control to work from osm.org in https on Windows systems by adding updated JOSM localhost certificate to Windows Root Certificates keystore

Location:
trunk/src/org/openstreetmap/josm/tools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/PlatformHook.java

    r6830 r7206  
    44import java.io.File;
    55import java.io.IOException;
     6import java.security.KeyStore;
     7import java.security.KeyStoreException;
     8import java.security.NoSuchAlgorithmException;
     9import java.security.cert.CertificateException;
    610
    711/**
     
    102106     */
    103107    public String getOSDescription();
     108
     109    /**
     110     * Setup system keystore to add JOSM HTTPS certificate (for remote control).
     111     * @param privateKeyEntry the JOSM certificate for localhost and associated private key
     112     * @throws KeyStoreException in case of error
     113     * @throws IOException in case of error
     114     * @throws CertificateException in case of error
     115     * @throws NoSuchAlgorithmException in case of error
     116     * @since 7206
     117     */
     118    public void setupHttpsCertificate(KeyStore.PrivateKeyEntry privateKeyEntry)
     119            throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException;
    104120}
  • trunk/src/org/openstreetmap/josm/tools/PlatformHookUnixoid.java

    r7082 r7206  
    1616import java.net.URISyntaxException;
    1717import java.nio.charset.StandardCharsets;
     18import java.security.KeyStore;
     19import java.security.KeyStoreException;
     20import java.security.NoSuchAlgorithmException;
     21import java.security.cert.CertificateException;
    1822import java.util.Arrays;
    1923
     
    2529
    2630/**
    27  * see PlatformHook.java
    28  *
    29  * BTW: THIS IS A STUB. See comments below for details.
     31 * {@code PlatformHook} base implementation.
    3032 *
    3133 * Don't write (Main.platform instanceof PlatformHookUnixoid) because other platform
     
    364366        });
    365367    }
     368
     369    @Override
     370    public void setupHttpsCertificate(KeyStore.PrivateKeyEntry privateKeyEntry)
     371            throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException {
     372        // TODO setup HTTPS certificate on Unix systems
     373    }
    366374}
  • trunk/src/org/openstreetmap/josm/tools/PlatformHookWindows.java

    r7001 r7206  
    3030import java.io.File;
    3131import java.io.IOException;
     32import java.security.KeyStore;
     33import java.security.KeyStoreException;
     34import java.security.NoSuchAlgorithmException;
     35import java.security.cert.Certificate;
     36import java.security.cert.CertificateException;
     37import java.util.Enumeration;
     38
     39import org.openstreetmap.josm.Main;
    3240
    3341/**
     
    129137                ((System.getenv("ProgramFiles(x86)") == null) ? "32" : "64") + "-Bit";
    130138    }
     139
     140    @Override
     141    public void setupHttpsCertificate(KeyStore.PrivateKeyEntry privateKeyEntry)
     142            throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException {
     143        KeyStore ks = KeyStore.getInstance("Windows-ROOT");
     144        ks.load(null, null);
     145        Enumeration<String> en = ks.aliases();
     146        while (en.hasMoreElements()) {
     147            String alias = en.nextElement();
     148            Certificate c = ks.getCertificate(alias);
     149            if (ks.isKeyEntry(alias) && c.equals(privateKeyEntry.getCertificate())) {
     150                // JOSM certificate found, return
     151                return;
     152            }
     153        }
     154        // JOSM certificate not found, install it
     155        Main.info("Adding JOSM localhost certificate to Windows-ROOT keystore");
     156        ks.setEntry("josm_localhost", privateKeyEntry, new KeyStore.PasswordProtection("josm_ssl".toCharArray()));
     157    }
    131158}
Note: See TracChangeset for help on using the changeset viewer.