Validate X509 certificates using Java APis

后端 未结 3 988
闹比i
闹比i 2020-12-01 12:50

I am trying to validate a certificate against java key store and this is the code I am using is as below. If it completes succesfully then I assume the validation has gone t

3条回答
  •  抹茶落季
    2020-12-01 13:14

    What you are doing here is verifying if a certificate (in your example cert) has been signed (directly) by any of the trusted CA's in the truststore.
    Additionally you check for expiration but no revocation checking is performed.
    So if the cert has not been signed by any of the trusted CA's you will get an exception.
    So the code is sufficient to verify if cert has been signed by any of the trusted CAs


    If you are refering to server authentication, then the code in the post is not sufficient.
    This code just verifies that a specific certificate is signed by a trusted CA.
    You have no indication though if the "entity" that send you this certificate is actually the owner of the certificate (i.e. they own the private key associated with this certificate).
    This is part of the SSL authentication, where e.g. the client sends the ClientKeyExchange message encrypted with the remote server's public key and is certain that if the other party is fake then it will not be possible to decrypt the message

提交回复
热议问题