return 0;
/* determine recipient entry in PKIHeader */
- if (ctx->srvCert != NULL) {
- rcp = X509_get_subject_name(ctx->srvCert);
- /* set also as expected_sender of responses unless set explicitly */
- if (ctx->expected_sender == NULL && rcp != NULL
- && !OSSL_CMP_CTX_set1_expected_sender(ctx, rcp))
- return 0;
- } else if (ctx->recipient != NULL) {
+ if (ctx->recipient != NULL)
rcp = ctx->recipient;
- } else if (ctx->issuer != NULL) {
+ else if (ctx->srvCert != NULL)
+ rcp = X509_get_subject_name(ctx->srvCert);
+ else if (ctx->issuer != NULL)
rcp = ctx->issuer;
- } else if (ctx->oldCert != NULL) {
+ else if (ctx->oldCert != NULL)
rcp = X509_get_issuer_name(ctx->oldCert);
- } else if (ctx->cert != NULL) {
+ else if (ctx->cert != NULL)
rcp = X509_get_issuer_name(ctx->cert);
- }
if (!ossl_cmp_hdr_set1_recipient(hdr, rcp))
return 0;
+ /* set also as expected_sender of responses unless set explicitly */
+ if (ctx->expected_sender == NULL && rcp != NULL
+ && !OSSL_CMP_CTX_set1_expected_sender(ctx, rcp))
+ return 0;
/* set current time as message time */
if (!ossl_cmp_hdr_update_messageTime(hdr))
X509_EXTENSIONS *exts = NULL;
if (rkey == NULL)
- rkey = ctx->pkey; /* default is independent of ctx->oldClCert */
+ rkey = ctx->pkey; /* default is independent of ctx->oldCert */
if (rkey == NULL) {
#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
CMPerr(0, CMP_R_NULL_ARGUMENT);
int nid = NID_undef, pk_nid = NID_undef;
const ASN1_OBJECT *algorOID = NULL;
X509 *scrt;
+ const X509_NAME *expected_sender;
if (ctx == NULL || msg == NULL
|| msg->header == NULL || msg->body == NULL) {
* Mitigates risk to accept misused certificate of an unauthorized
* entity of a trusted hierarchy.
*/
+ expected_sender = ctx->expected_sender;
+ if (expected_sender == NULL && ctx->srvCert != NULL)
+ expected_sender = X509_get_subject_name(ctx->srvCert);
if (!check_name(ctx, "sender DN field",
msg->header->sender->d.directoryName,
- "expected sender", ctx->expected_sender))
+ "expected sender", expected_sender))
break;
/* Note: if recipient was NULL-DN it could be learned here if needed */