As comments already indicate, using the getSignature
method you do get the signature. It is a byte[]
, though. Thus, you should not expect anything usable from its toString
value.
Concerning your original objective, though:
verify this certificate if it is intact or not by verifying the signature.
You do not need to do all that stuff manually. Instead your should use the Certificate
methods getPublicKey
and verify
:
boolean check (Certificate testCert, Certificate caCert)
{
try
{
testCert.verify(caCert.getPublicKey());
return true;
}
catch (GeneralSecurityException e)
{
return false;
}
]
Depending on the algorithms used you may need to use the other verify overload to supply an explicit provider.
For those in doubt the according Certificate
method comments:
/**
* Verifies that this certificate was signed using the
* private key that corresponds to the specified public key.
*
* @param key the PublicKey used to carry out the verification.
*
* ...
*/
public abstract void verify(PublicKey key)
/**
* Gets the public key from this certificate.
*
* @return the public key.
*/
public abstract PublicKey getPublicKey()