return msg->body->type;
}
+X509_PUBKEY *OSSL_CMP_MSG_get0_certreq_publickey(const OSSL_CMP_MSG *msg)
+{
+ const OSSL_CRMF_MSGS *reqs;
+ const OSSL_CRMF_MSG *crm;
+ const OSSL_CRMF_CERTTEMPLATE *tmpl;
+ X509_PUBKEY *pubkey;
+
+ switch (OSSL_CMP_MSG_get_bodytype(msg)) {
+ case OSSL_CMP_PKIBODY_IR:
+ case OSSL_CMP_PKIBODY_CR:
+ case OSSL_CMP_PKIBODY_KUR:
+ reqs = msg->body->value.ir; /* value.ir is same for cr and kur */
+ if ((crm = sk_OSSL_CRMF_MSG_value(reqs, 0)) == NULL) {
+ ERR_raise(ERR_LIB_CMP, CMP_R_CERTREQMSG_NOT_FOUND);
+ return NULL;
+ }
+ if ((tmpl = OSSL_CRMF_MSG_get0_tmpl(crm)) == NULL
+ || (pubkey = OSSL_CRMF_CERTTEMPLATE_get0_publicKey(tmpl)) == NULL) {
+ ERR_raise(ERR_LIB_CMP, CRMF_R_POPO_MISSING_PUBLIC_KEY);
+ return NULL;
+ }
+ return pubkey;
+ default:
+ ERR_raise(ERR_LIB_CMP, CMP_R_UNEXPECTED_PKIBODY);
+ return NULL;
+ }
+}
+
/* Add an extension to the referenced extension stack, which may be NULL */
static int add1_extension(X509_EXTENSIONS **pexts, int nid, int crit, void *ex)
{
} else if (ctx->p10CSR != NULL) {
pubkey = X509_REQ_get0_pubkey(ctx->p10CSR);
subject = X509_REQ_get_subject_name(ctx->p10CSR);
- }
- else {
+ } else {
goto err;
}