What is loadTrustMaterial in sslContext? | Mutual TLS

Viewed 86

I am trying to setup RestTemplate for mutual TLS, I need to verify servers certificate with CAs I trust.

sslContext = SSLContexts.custom()
                        .setKeyStoreType("PKCS12")
                        .loadKeyMaterial(getKeystore(), StaticCMDArgsProvider.INSTANCE.getKeystorePass().toCharArray())
                        .loadTrustMaterial(getTruststore(), acceptingTrustStrategy)
                        .build();

Here I am confused as to what loadTrustMaterial does? I believe first parameter is the CAs we trust and second is the way to verify servers certificate with the CAs I trust? I'm not sure.

Currently my acceptingTrustStrategy returns true unconditionally, What is good example of a acceptingTrustStrategy ?

Thanks.

0 Answers
Related