ref_put ( &root->refcnt );
}
+/**
+ * Check if X.509 certificate is self-signed
+ *
+ * @v cert X.509 certificate
+ * @ret is_self_signed X.509 certificate is self-signed
+ */
+static inline int x509_is_self_signed ( struct x509_certificate *cert ) {
+ return ( asn1_compare ( &cert->issuer.raw, &cert->subject.raw ) == 0 );
+}
+
extern const char * x509_name ( struct x509_certificate *cert );
extern int x509_parse ( struct x509_certificate *cert,
const struct asn1_cursor *raw );
* nothing more to do.
*/
last = x509_last ( validator->chain );
- if ( asn1_compare ( &last->issuer.raw, &last->subject.raw ) == 0 ) {
+ if ( x509_is_self_signed ( last ) ) {
validator_finished ( validator, rc );
return;
}
x509_validate_chain_fail_ok ( &server_chain, test_time,
&empty_store, &test_root );
+ /* Check self-signedess */
+ ok ( x509_is_self_signed ( root_crt.cert ) );
+ ok ( ! x509_is_self_signed ( intermediate_crt.cert ) );
+
/* Sanity check */
assert ( list_empty ( &empty_store.links ) );