Here is a sample code I am referring to. https://sites.google.com/site/ssljavaguide/example-code/2-way-ssl

Can I not set the keystore-related properties and wait for some exception to be thrown and then depending upon the occurrence of exception decide whether it is a 1-way or 2-way ssl connection?

Apologies if the question seems stupid.

有帮助吗?

解决方案

It's up to the server to request a client certificate (the client cannot send it if it's not requested).

Your client keystore will only be used if the server makes such a request. Setting a keystore when no client certificate is requested is not a problem: it just won't be used. The side effect is that the client will send a suitable cert whenever it's requested. If you need a bit more control, you'll need a custom KeyManager.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top