#include <ipxe/socket.h>
#include <ipxe/in.h>
#include <ipxe/image.h>
+#include <ipxe/ocsp.h>
#include <ipxe/x509.h>
#include <config/crypto.h>
}
/* Fail if OCSP is required */
- if ( cert->extensions.auth_info.ocsp.uri.len &&
- ( ! cert->extensions.auth_info.ocsp.good ) ) {
+ if ( ocsp_required ( cert ) ) {
DBGC ( cert, "X509 %p \"%s\" requires an OCSP check\n",
cert, x509_name ( cert ) );
return -EACCES_OCSP_REQUIRED;
ref_put ( &ocsp->refcnt );
}
+/**
+ * Check if X.509 certificate requires an OCSP check
+ *
+ * @v cert X.509 certificate
+ * @ret ocsp_required An OCSP check is required
+ */
+static inline int ocsp_required ( struct x509_certificate *cert ) {
+
+ /* An OCSP check is required if an OCSP URI exists but the
+ * OCSP status is not (yet) good.
+ */
+ return ( cert->extensions.auth_info.ocsp.uri.len &&
+ ( ! cert->extensions.auth_info.ocsp.good ) );
+}
+
extern int ocsp_check ( struct x509_certificate *cert,
struct x509_certificate *issuer,
struct ocsp_check **ocsp );
/* The issuer is valid, but this certificate is not
* yet valid. If OCSP is applicable, start it.
*/
- if ( cert->extensions.auth_info.ocsp.uri.len &&
- ( ! cert->extensions.auth_info.ocsp.good ) ) {
+ if ( ocsp_required ( cert ) ) {
/* Start OCSP */
if ( ( rc = validator_start_ocsp ( validator, cert,
issuer ) ) != 0 ) {