mirror of
https://github.com/pocoproject/poco.git
synced 2024-12-16 11:48:54 +01:00
added X509Certificate::equals()
This commit is contained in:
parent
53353d6ec1
commit
fdd68b17f3
@ -130,6 +130,14 @@ public:
|
||||
/// Returns true if verification against the issuer certificate
|
||||
/// was successful, false otherwise.
|
||||
|
||||
bool equals(const X509Certificate& otherCertificate) const;
|
||||
/// Checks whether the certificate is equal to
|
||||
/// the other certificate, by comparing the hashes
|
||||
/// of both certificates.
|
||||
///
|
||||
/// Returns true if both certificates are identical,
|
||||
/// otherwise false.
|
||||
|
||||
const X509* certificate() const;
|
||||
/// Returns the underlying OpenSSL certificate.
|
||||
|
||||
|
@ -284,4 +284,12 @@ bool X509Certificate::issuedBy(const X509Certificate& issuerCertificate) const
|
||||
}
|
||||
|
||||
|
||||
bool X509Certificate::equals(const X509Certificate& otherCertificate) const
|
||||
{
|
||||
X509* pCert = const_cast<X509*>(_pCert);
|
||||
X509* pOtherCert = const_cast<X509*>(otherCertificate.certificate());
|
||||
return X509_cmp(pCert, pOtherCert) == 0;
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Crypto
|
||||
|
@ -304,6 +304,11 @@ void CryptoTest::testCertificate()
|
||||
|
||||
// fails with recent OpenSSL versions:
|
||||
// assert (cert.issuedBy(cert));
|
||||
|
||||
std::istringstream otherCertStream(APPINF_PEM);
|
||||
X509Certificate otherCert(otherCertStream);
|
||||
|
||||
assert (cert.equals(otherCert));
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user