Changeset 7343 in josm for trunk/src/org/openstreetmap/josm/tools
- Timestamp:
- 2014-07-28T16:40:19+02:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/tools
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/PlatformHook.java
r7335 r7343 109 109 /** 110 110 * Setup system keystore to add JOSM HTTPS certificate (for remote control). 111 * @param entryAlias The entry alias to use 111 112 * @param trustedCert the JOSM certificate for localhost 113 * @return {@code true} if something has changed as a result of the call (certificate installation, etc.) 112 114 * @throws KeyStoreException in case of error 113 115 * @throws IOException in case of error 114 116 * @throws CertificateException in case of error 115 117 * @throws NoSuchAlgorithmException in case of error 116 * @since 7 206118 * @since 7343 117 119 */ 118 public void setupHttpsCertificate(KeyStore.TrustedCertificateEntry trustedCert)120 public boolean setupHttpsCertificate(String entryAlias, KeyStore.TrustedCertificateEntry trustedCert) 119 121 throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException; 120 122 } -
trunk/src/org/openstreetmap/josm/tools/PlatformHookUnixoid.java
r7335 r7343 358 358 359 359 @Override 360 public void setupHttpsCertificate(KeyStore.TrustedCertificateEntry trustedCert)360 public boolean setupHttpsCertificate(String entryAlias, KeyStore.TrustedCertificateEntry trustedCert) 361 361 throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException { 362 362 // TODO setup HTTPS certificate on Unix systems 363 return false; 363 364 } 364 365 } -
trunk/src/org/openstreetmap/josm/tools/PlatformHookWindows.java
r7342 r7343 181 181 * @throws IOException if there is an I/O or format problem with the keystore data, if a password is required but not given 182 182 * @throws KeyStoreException if no Provider supports a KeyStore implementation for the type "Windows-ROOT" 183 * @since 7343 183 184 */ 184 p rivate KeyStore getWindowsKeystore() throws NoSuchAlgorithmException, CertificateException, IOException, KeyStoreException {185 public static KeyStore getRootKeystore() throws NoSuchAlgorithmException, CertificateException, IOException, KeyStoreException { 185 186 KeyStore ks = KeyStore.getInstance(WINDOWS_ROOT); 186 187 ks.load(null, null); … … 196 197 * @since 7335 197 198 */ 198 public void removeInsecureCertificates() throws NoSuchAlgorithmException, CertificateException, KeyStoreException, IOException {199 public static void removeInsecureCertificates() throws NoSuchAlgorithmException, CertificateException, KeyStoreException, IOException { 199 200 // We offered before a public private key we need now to remove from Windows PCs as it might be a huge security risk (see #10230) 200 201 PublicKey insecurePubKey = null; … … 205 206 return; 206 207 } 207 KeyStore ks = get WindowsKeystore();208 KeyStore ks = getRootKeystore(); 208 209 Enumeration<String> en = ks.aliases(); 209 210 Collection<String> insecureCertificates = new ArrayList<>(); … … 249 250 250 251 @Override 251 public void setupHttpsCertificate(KeyStore.TrustedCertificateEntry trustedCert)252 public boolean setupHttpsCertificate(String entryAlias, KeyStore.TrustedCertificateEntry trustedCert) 252 253 throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException { 253 KeyStore ks = getWindowsKeystore(); 254 Enumeration<String> en = ks.aliases(); 255 256 while (en.hasMoreElements()) { 257 String alias = en.nextElement(); 258 // Look for certificate to install 259 if (ks.getCertificate(alias).equals(trustedCert.getTrustedCertificate())) { 260 // JOSM certificate found, return 261 Main.debug("JOSM certificate found: "+alias); 262 return; 263 } 254 KeyStore ks = getRootKeystore(); 255 // Look for certificate to install 256 String alias = ks.getCertificateAlias(trustedCert.getTrustedCertificate()); 257 if (alias != null) { 258 // JOSM certificate found, return 259 Main.debug(tr("JOSM localhost certificate found in {0} keystore: {1}", WINDOWS_ROOT, alias)); 260 return false; 264 261 } 265 262 // JOSM certificate not found, install it to Windows-ROOT keystore, used by IE, Chrome and Safari, but not by Firefox 266 263 Main.info(tr("Adding JOSM localhost certificate to {0} keystore", WINDOWS_ROOT)); 267 ks.setEntry("josm_localhost", trustedCert, null); 264 ks.setEntry(entryAlias, trustedCert, null); 265 return true; 268 266 } 269 267 }
Note: See TracChangeset
for help on using the changeset viewer.