I need to setup a javax.net.ssl.SSLContext
for use in a Jersey-Client application. All I want to do is the context to accept a custom root ca certificate. Is is really true that there is no way around of generating a keystore file and importing the CA certificate?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
There are way to do it without a keystore file, but since you would have to load the CA certificate you want to trust one way or another, you'll have to load a file or resource somehow.
(You could also certainly implement your own
TrustManager
that makes all the calls to use the Certification Path API, without using theKeyStore
API at all, but that would only increase the complexity of your code, not reduce it. You would also need to understand the Java PKI Programmer's Guide to do this correctly.)If you really don't want a keystore file, you could use the
KeyStore
API in memory and load the certificate directly.Something along these lines should work (not tested):
(Remember to close everything and handle the exceptions.)
Whether loading the certificate this way or loading the certificate into a similar
KeyStore
instance from a keystore file is more convenient is up to you to decide.