Sticky
Sticky

Reputation: 1082

Programmatically getting Certificate Details

I have a self-signed JAR file. I would like for it to be able to:

  1. Check if it is signed;
  2. Get and output the details of the certificate it was signed with.

The jar does not need to check or verify the certificate with a server.

Any help would be appreciated. Thanks! :)

Upvotes: 2

Views: 1330

Answers (1)

BalusC
BalusC

Reputation: 1108722

Use CodeSource#getCertificates().

Certificate[] certificates = YourClass.class.getProtectionDomain().getCodeSource().getCertificates();

Upvotes: 2

Related Questions