Support different encoding types in certificate.get_encoding()
This commit is contained in:
@@ -296,10 +296,16 @@ METHOD(certificate_t, get_validity, bool,
|
||||
return t <= this->nextUpdate;
|
||||
}
|
||||
|
||||
METHOD(certificate_t, get_encoding, chunk_t,
|
||||
private_openssl_crl_t *this)
|
||||
METHOD(certificate_t, get_encoding, bool,
|
||||
private_openssl_crl_t *this, cred_encoding_type_t type, chunk_t *encoding)
|
||||
{
|
||||
return chunk_clone(this->encoding);
|
||||
if (type == CERT_ASN1_DER)
|
||||
{
|
||||
*encoding = chunk_clone(this->encoding);
|
||||
return TRUE;
|
||||
}
|
||||
return lib->encoding->encode(lib->encoding, type, NULL, encoding,
|
||||
CRED_PART_X509_CRL_ASN1_DER, this->encoding, CRED_PART_END);
|
||||
}
|
||||
|
||||
METHOD(certificate_t, equals, bool,
|
||||
@@ -317,7 +323,10 @@ METHOD(certificate_t, equals, bool,
|
||||
return chunk_equals(this->encoding,
|
||||
((private_openssl_crl_t*)other)->encoding);
|
||||
}
|
||||
encoding = other->get_encoding(other);
|
||||
if (!other->get_encoding(other, CERT_ASN1_DER, &encoding))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
equal = chunk_equals(this->encoding, encoding);
|
||||
free(encoding.ptr);
|
||||
return equal;
|
||||
|
||||
@@ -393,12 +393,19 @@ METHOD(certificate_t, get_validity, bool,
|
||||
return (t >= this->notBefore && t <= this->notAfter);
|
||||
}
|
||||
|
||||
METHOD(certificate_t, get_encoding, chunk_t,
|
||||
private_openssl_x509_t *this)
|
||||
METHOD(certificate_t, get_encoding, bool,
|
||||
private_openssl_x509_t *this, cred_encoding_type_t type, chunk_t *encoding)
|
||||
{
|
||||
return chunk_clone(this->encoding);
|
||||
if (type == CERT_ASN1_DER)
|
||||
{
|
||||
*encoding = chunk_clone(this->encoding);
|
||||
return TRUE;
|
||||
}
|
||||
return lib->encoding->encode(lib->encoding, type, NULL, encoding,
|
||||
CRED_PART_X509_ASN1_DER, this->encoding, CRED_PART_END);
|
||||
}
|
||||
|
||||
|
||||
METHOD(certificate_t, equals, bool,
|
||||
private_openssl_x509_t *this, certificate_t *other)
|
||||
{
|
||||
@@ -418,7 +425,10 @@ METHOD(certificate_t, equals, bool,
|
||||
encoding = ((private_openssl_x509_t*)other)->encoding;
|
||||
return chunk_equals(this->encoding, encoding);
|
||||
}
|
||||
encoding = other->get_encoding(other);
|
||||
if (!other->get_encoding(other, CERT_ASN1_DER, &encoding))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
equal = chunk_equals(this->encoding, encoding);
|
||||
free(encoding.ptr);
|
||||
return equal;
|
||||
|
||||
Reference in New Issue
Block a user