开发者

How to read issuer String from user's public key?

I want to read issuer String from 开发者_开发知识库user's public key with Bouncy Castle. Is there example code or something from which I can learn?


If you can obtain the certificate object, then you can do the following:

((X509Certificate) certificate).getIssuerX500Principal().getName();

The public key itself does not have an issuer - only a certificate has. And you can get the public key from the certificate, but not vice-versa.

Update: Since it appears that you want to verify the validity of your users, the public key alone does not provide this info. Public keys are used for encryption / digital signature verification, but for the rest of PKI you need the certificate. Actually, verifying the issuer that is written in the certificate gives you no guarantee whatsoever. You need to check:

  • the certificate revocation lists - i.e. whether the certificate is not revoked. This is done either via the provided CRLs or via the ocsp protocol.
  • the expiration of the certificate


The public key object doesn't say who generated it. It just contains what you need to encrypt (or verify) with the public key.

If you got the public key from a certificate (java.security.cert.X509Certificate), then you can get the certificate issuer from that by using getIssuerX500Principal().

The certificate is a binding of an identity to a public key. As part of that, the certificate indicates who it was issued by. So you can verify whether you trust that issuer and, therefore, the binding.

Also, the key pair very likely wasn't generated by the certificate issuer. The subject just proved to the issuer that it did possess the associated private key.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜