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 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 method in shared JVM 7:49 Example project that shows how to create truststore programatically and set it via 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 but gets PKIX exception since using custom truststore cleared the default certs 11:52 Fourth test case that uses cacerts and calls 12:50 Explanation of @BeforeClass annotation in Junit which keeps a copy of SSLContext and @Before annotation method resets the 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: 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: Google Searches: #62723153 #62723153











