Use Client Certificate Authentication with Java and RestTemplate

As a follow up of the http://gochev.blogspot.com/2019/04/convert-pfx-certificate-to-jks-p12-crt.html we now have a keystore and a truststore (if anyone needs) and we will use this keystore to send client side authentication using Spring's RestTemplate .First copy your keystore.jks and truststore.jks in your classpath, no one wants absolute paths right ?:)The magic happens in the creation of SSLContext. Keep in mind the Spring Boot have a nice RestTemplateBuilder but I will not gonna use it, because someone of you might have an older version or like me, might just use a plain old amazing Spring.If you just want to use the keystore:final String allPassword = "123456";SSLContext sslContext = SSLContextBuilder                .create()                .loadKeyMaterial(ResourceUtils.getFile("classpath:keystore.jks"),                                    allPassword.toCharArray(), allPassword.toCharArray())                .build();if you just want to use the truststorefinal String allPassword = "123456";SSLContext sslContext = SSLContextBuilder                .create()                .loadTrustMaterial(ResourceUtils.getFile("classpath:truststore.jks"), allPassword.toCharArray())                .build();I guess you know how to use both ;), if you want to IGNORE the truststore certificate checking and trust ALL certificates (might be handy for testing purposes and localhost)final String allPassword = "123456";TrustStrategy acceptingTrustStrategy = (X509Certificate[] chain, String authType) -> true;SSLContext sslContext = SSLContextBuilder                .create()                .loadTrustMaterial(ResourceUtils.getFile("classpath:truststore.jks"), allPassword.toCharArray())                .loadTrustMaterial(null, acceptingTrustStrategy) //accept all                .build();Ones you have the sslContext...

Introduction to Spring MVC (In Bulgarian)

This is video from the presentation I did for Software University  at Sofia, Bulgaria. Camera : Screen capture : All demos can be downloaded from here https://github.com/gochev/examples/tree/master/SoftUni%20Spring%20MVC%20June%202015 If you missed the event .. don't miss the next one. In Bulgarian Java User Group we do events like this one every month. Information about past and future events can be found here...

Introduction to Spring MVC (In Bulgarian)

This is video from the presentation I did for Software University  at Sofia, Bulgaria. Camera : Screen capture : All demos can be downloaded from here https://github.com/gochev/examples/tree/master/SoftUni%20Spring%20MVC%20June%202015 If you missed the event .. don't miss the next one. In Bulgarian Java User Group we do events like this one every month. Information about past and future events can be found here...

Introduction to Spring MVC (In Bulgarian)

This is video from the presentation I did for Software University  at Sofia, Bulgaria. Camera : Screen capture : All demos can be downloaded from here https://github.com/gochev/examples/tree/master/SoftUni%20Spring%20MVC%20June%202015 If you missed the event .. don't miss the next one. In Bulgarian Java User Group we do events like this one every month. Information about past and future events can be found here...

ORM в Java: Hibernate и JPA

A talk about Java and ORM I made at Software University in Bulgaria few months ago. It shows Hibernate (old school stuff) and JPA to as ORM. The talk is in Bulgarian Examples on github can be found here : Hibernate example JPA...