Last active
August 29, 2015 13:57
-
-
Save ehdez73/9474983 to your computer and use it in GitHub Desktop.
SSL with RestTemplate to external Host
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import org.springframework.web.client.RestTemplate; | |
| public class Application { | |
| static { | |
| System.setProperty("javax.net.ssl.trustStore", "/opt/cert/trustStore"); | |
| System.setProperty("javax.net.ssl.trustStorePassword", "s3cret"); | |
| } | |
| public static void main(String[] args) throws Exception { | |
| /** | |
| * Previamente hay que importar el certificado de Google | |
| * $ wget http://pki.google.com/GIAG2.crt | |
| * $ keytool -keystore tomcat.keystore -alias google -import -file GIAG2.crt | |
| */ | |
| RestTemplate restTemplate = new RestTemplate(); | |
| String message = restTemplate.getForObject("https://www.google.es", String.class); | |
| System.out.println(message); // output HTML | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment