Changeset 13458 in josm for trunk/src/org/openstreetmap/josm/tools/PlatformHookWindows.java
- Timestamp:
- 2018-02-25T14:57:23+01:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/PlatformHookWindows.java
r13451 r13458 447 447 // using (Get-ItemProperty -Path 'HKLM:\\SOFTWARE\\Microsoft\\SystemCertificates\\AuthRoot\\AutoUpdate').EncodedCtl) 448 448 // then decode it using CertUtil -dump or calling CertCreateCTLContext API using JNI, and finally find and decode the certificate 449 try { 450 // https://stackoverflow.com/a/41618979/2257172 451 Utils.execOutput(Arrays.asList("powershell", "-Command", 452 "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;" + 453 "Invoke-WebRequest " + certAmend.getWebSite())); 454 } catch (ExecutionException | InterruptedException e) { 455 Logging.error(e); 456 } 449 Logging.trace(webRequest(certAmend.getWebSite())); 457 450 // Get Windows Trust Root Store 458 451 KeyStore ks = getRootKeystore(); … … 696 689 return def; 697 690 } 691 692 /** 693 * Performs a web request using Windows CryptoAPI (through PowerShell). 694 * This is useful to ensure Windows trust store will contain a specific root CA. 695 * @param uri the web URI to request 696 * @return HTTP response from the given URI 697 * @throws IOException if any I/O error occurs 698 * @since 13458 699 */ 700 public static String webRequest(String uri) throws IOException { 701 // With PS 6.0 (not yet released in Windows) we could simply use: 702 // Invoke-WebRequest -SSlProtocol Tsl12 $uri 703 // With PS 3.0 (Windows 8+) we can use (https://stackoverflow.com/a/41618979/2257172): 704 // [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; Invoke-WebRequest $uri 705 // Unfortunately there are still a lot of users with Windows 7 (PS 2.0) and Invoke-WebRequest is not available: 706 try { 707 // https://stackoverflow.com/a/25121601/2257172 708 return Utils.execOutput(Arrays.asList("powershell", "-Command", 709 "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;"+ 710 "[System.Net.WebRequest]::Create('"+uri+"').GetResponse()" 711 )); 712 } catch (ExecutionException | InterruptedException e) { 713 Logging.error(e); 714 return null; 715 } 716 } 698 717 }
Note:
See TracChangeset
for help on using the changeset viewer.