Java programmatically add custom trusted + default certificates using SSLContext setDefault

Veröffentlicht am: 05 Februar 2023
auf dem Kanal: Rahul Random Learnings
3,127
40

Using a custom truststore in java as well as the default one with SSLContext setDefault

In this video we are going to setup truststore load certificates in it programmatically and then include all the certificates from JDK default lib/security/cacerts bundle as well and then set our truststore as default via SSLContext.setDefault method.

0:17 What is a cacert file

1:55 Location of cacerts file in JDK 8, 11, 18

2:25 Please Like and Subscribe!

2:33 What is SSLContext

4:41 Example of impact of setting SSLContext.setDefault method in shared JVM

7:49 Example project that shows how to create truststore programatically and set it via SSLContext.setDefault

8:14 First testcase that shows PKIX Exception for untrusted root certificate

9:36 Second test case that creates truststore programatically and then calls URL with untrusted root certificate

11:20 Third test case that calls google.com but gets PKIX exception since using custom truststore cleared the default certs

11:52 Fourth test case that uses cacerts and calls google.com

12:50 Explanation of @BeforeClass annotation in Junit which keeps a copy of SSLContext and @Before annotation method resets the SSLContext.setDfault so that each test case can run properly

14:46 Test case that covers code that adds custom SSL certificate to truststore including the default cacerts certificate bundle.

Example Project Code:
https://github.com/chandnarahul/impor...

This video covers:
How to create truststore and retain all cacerts certificates in it
How to create truststore and include all cacert certificates in it
How to create truststore and add all JDK cacert certificates in it
Using a custom truststore in java as well as the default one
How to create a certificate store from existing certificates in Java
Add custom SSL certificate to truststore but retain the default cacerts in Java

Supporting Links:
https://untrusted-root.badssl.com/
https://www.websecurity.digicert.com/...

Google Searches:
https://stackoverflow.com/questions/2...
https://stackoverflow.com/questions/4...
https://stackoverflow.com/questions/2...


Auf dieser Seite können Sie das Online-Video Java programmatically add custom trusted + default certificates using SSLContext setDefault mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Rahul Random Learnings 05 Februar 2023 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 3,127 Mal angesehen und es wurde von 40 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!