am trying to get the response code of a https url with URL class. The sites with registered authority like verisign works well. But when I try with a server with its own certificate it resulted in an exception.
I referred and created a new cacerts file as mentioned in blog
But now I didn’t get the exception but a status code of 400. Will the new cacerts be applicable to all the URLs of that particular domain.
Thanks.
When you get an HTTP status then SSL has been performed correctly and you don’t need to look at the certificates again. SSL is always performed before any HTTP requests/responses. The problem you now have is that the URL is malformed, the server probably expects some kind of query or ID or other application specific data.
Cacerts are always applicable for any server name – it is the underlying SSL certificate that the server sends to the client that first gets validated. This certificate (normally not the one in the cacerts file) contains the name (any full DNS name!).
From the RFC:
400 Bad Request
The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request without modifications.