mirror of
https://github.com/QuasarApp/openssl.git
synced 2025-04-29 11:14:36 +00:00
bugfix in apps/cmp.c and cmp_client.c: inconsistencies on retrieving extraCerts in code and doc
Reviewed-by: Tim Hudson <tjh@openssl.org> (Merged from https://github.com/openssl/openssl/pull/12822)
This commit is contained in:
parent
543a802fab
commit
bb30bce22b
40
apps/cmp.c
40
apps/cmp.c
@ -2818,27 +2818,27 @@ int cmp_main(int argc, char **argv)
|
||||
switch (opt_cmd) {
|
||||
case CMP_IR:
|
||||
newcert = OSSL_CMP_exec_IR_ses(cmp_ctx);
|
||||
if (newcert == NULL)
|
||||
goto err;
|
||||
if (newcert != NULL)
|
||||
ret = 1;
|
||||
break;
|
||||
case CMP_KUR:
|
||||
newcert = OSSL_CMP_exec_KUR_ses(cmp_ctx);
|
||||
if (newcert == NULL)
|
||||
goto err;
|
||||
if (newcert != NULL)
|
||||
ret = 1;
|
||||
break;
|
||||
case CMP_CR:
|
||||
newcert = OSSL_CMP_exec_CR_ses(cmp_ctx);
|
||||
if (newcert == NULL)
|
||||
goto err;
|
||||
if (newcert != NULL)
|
||||
ret = 1;
|
||||
break;
|
||||
case CMP_P10CR:
|
||||
newcert = OSSL_CMP_exec_P10CR_ses(cmp_ctx);
|
||||
if (newcert == NULL)
|
||||
goto err;
|
||||
if (newcert != NULL)
|
||||
ret = 1;
|
||||
break;
|
||||
case CMP_RR:
|
||||
if (OSSL_CMP_exec_RR_ses(cmp_ctx) == NULL)
|
||||
goto err;
|
||||
if (OSSL_CMP_exec_RR_ses(cmp_ctx) != NULL)
|
||||
ret = 1;
|
||||
break;
|
||||
case CMP_GENM:
|
||||
{
|
||||
@ -2852,10 +2852,11 @@ int cmp_main(int argc, char **argv)
|
||||
OSSL_CMP_CTX_push0_genm_ITAV(cmp_ctx, itav);
|
||||
}
|
||||
|
||||
if ((itavs = OSSL_CMP_exec_GENM_ses(cmp_ctx)) == NULL)
|
||||
goto err;
|
||||
print_itavs(itavs);
|
||||
sk_OSSL_CMP_ITAV_pop_free(itavs, OSSL_CMP_ITAV_free);
|
||||
if ((itavs = OSSL_CMP_exec_GENM_ses(cmp_ctx)) != NULL) {
|
||||
print_itavs(itavs);
|
||||
sk_OSSL_CMP_ITAV_pop_free(itavs, OSSL_CMP_ITAV_free);
|
||||
ret = 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@ -2863,7 +2864,7 @@ int cmp_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
{
|
||||
/* print PKIStatusInfo (this is in case there has been no error) */
|
||||
/* print PKIStatusInfo */
|
||||
int status = OSSL_CMP_CTX_get_status(cmp_ctx);
|
||||
char *buf = app_malloc(OSSL_CMP_PKISI_BUFLEN, "PKIStatusInfo buf");
|
||||
const char *string =
|
||||
@ -2885,11 +2886,14 @@ int cmp_main(int argc, char **argv)
|
||||
OPENSSL_free(buf);
|
||||
}
|
||||
|
||||
if (save_free_certs(cmp_ctx, OSSL_CMP_CTX_get1_caPubs(cmp_ctx),
|
||||
opt_cacertsout, "CA") < 0)
|
||||
goto err;
|
||||
if (save_free_certs(cmp_ctx, OSSL_CMP_CTX_get1_extraCertsIn(cmp_ctx),
|
||||
opt_extracertsout, "extra") < 0)
|
||||
ret = 0;
|
||||
if (!ret)
|
||||
goto err;
|
||||
ret = 0;
|
||||
if (save_free_certs(cmp_ctx, OSSL_CMP_CTX_get1_caPubs(cmp_ctx),
|
||||
opt_cacertsout, "CA") < 0)
|
||||
goto err;
|
||||
if (newcert != NULL) {
|
||||
STACK_OF(X509) *certs = sk_X509_new_null();
|
||||
|
@ -190,6 +190,11 @@ static int send_receive_check(OSSL_CMP_CTX *ctx, const OSSL_CMP_MSG *req,
|
||||
*/
|
||||
ossl_cmp_log1(INFO, ctx, "received %s", ossl_cmp_bodytype_to_string(bt));
|
||||
|
||||
/* copy received extraCerts to ctx->extraCertsIn so they can be retrieved */
|
||||
if (bt != OSSL_CMP_PKIBODY_POLLREP && bt != OSSL_CMP_PKIBODY_PKICONF
|
||||
&& !ossl_cmp_ctx_set1_extraCertsIn(ctx, (*rep)->extraCerts))
|
||||
return 0;
|
||||
|
||||
if (!ossl_cmp_msg_check_update(ctx, *rep, unprotected_exception,
|
||||
expected_type))
|
||||
return 0;
|
||||
@ -470,7 +475,7 @@ static X509 *get1_cert_status(OSSL_CMP_CTX *ctx, int bodytype,
|
||||
/*-
|
||||
* Callback fn validating that the new certificate can be verified, using
|
||||
* ctx->certConf_cb_arg, which has been initialized using opt_out_trusted, and
|
||||
* ctx->untrusted, which at this point already contains ctx->extraCertsIn.
|
||||
* ctx->untrusted, which at this point already contains msg->extraCerts.
|
||||
* Returns 0 on acceptance, else a bit field reflecting PKIFailureInfo.
|
||||
* Quoting from RFC 4210 section 5.1. Overall PKI Message:
|
||||
* The extraCerts field can contain certificates that may be useful to
|
||||
@ -595,10 +600,6 @@ static int cert_response(OSSL_CMP_CTX *ctx, int sleep, int rid,
|
||||
&& !ossl_cmp_ctx_set1_caPubs(ctx, crepmsg->caPubs))
|
||||
return 0;
|
||||
|
||||
/* copy received extraCerts to ctx->extraCertsIn so they can be retrieved */
|
||||
if (!ossl_cmp_ctx_set1_extraCertsIn(ctx, (*resp)->extraCerts))
|
||||
return 0;
|
||||
|
||||
subj = X509_NAME_oneline(X509_get_subject_name(cert), NULL, 0);
|
||||
if (rkey != NULL
|
||||
/* X509_check_private_key() also works if rkey is just public key */
|
||||
@ -606,8 +607,8 @@ static int cert_response(OSSL_CMP_CTX *ctx, int sleep, int rid,
|
||||
fail_info = 1 << OSSL_CMP_PKIFAILUREINFO_incorrectData;
|
||||
txt = "public key in new certificate does not match our enrollment key";
|
||||
/*-
|
||||
* not callling (void)ossl_cmp_exchange_error(ctx,
|
||||
* OSSL_CMP_PKISTATUS_rejection, fail_info, txt)
|
||||
* not calling (void)ossl_cmp_exchange_error(ctx,
|
||||
* OSSL_CMP_PKISTATUS_rejection, fail_info, txt)
|
||||
* not throwing CMP_R_CERTIFICATE_NOT_ACCEPTED with txt
|
||||
* not returning 0
|
||||
* since we better leave this for the certConf_cb to decide
|
||||
|
@ -590,13 +590,13 @@ with a signature key."
|
||||
|
||||
=item B<-extracertsout> I<filename>
|
||||
|
||||
The file where to save any extra certificates received in the extraCerts field
|
||||
of response messages.
|
||||
The file where to save all certificates contained in the extraCerts field
|
||||
of the last received response message (except for pollRep and PKIConf).
|
||||
|
||||
=item B<-cacertsout> I<filename>
|
||||
|
||||
The file where to save any CA certificates received in the caPubs field of
|
||||
Initialization Response (IP) messages.
|
||||
The file where to save any CA certificates contained in the caPubs field of
|
||||
the last received certificate response (i.e., IP, CP, or KUP) message.
|
||||
|
||||
=back
|
||||
|
||||
|
@ -617,14 +617,14 @@ OSSL_CMP_CTX_get1_newChain() returns a pointer to a duplicate of the stack of
|
||||
X.509 certificates computed by OSSL_CMP_certConf_cb() (if this function has
|
||||
been called) on the last received certificate response message IP/CP/KUP.
|
||||
|
||||
OSSL_CMP_CTX_get1_caPubs() returns a pointer to a duplicate of the stack of
|
||||
OSSL_CMP_CTX_get1_caPubs() returns a pointer to a duplicate of the list of
|
||||
X.509 certificates received in the caPubs field of last received certificate
|
||||
response message IP/CP/KUP.
|
||||
|
||||
OSSL_CMP_CTX_get1_extraCertsIn() returns a pointer to a duplicate of the stack
|
||||
of X.509 certificates received in the last received nonempty extraCerts field.
|
||||
Returns an empty stack if no extraCerts have been received in the current
|
||||
transaction.
|
||||
OSSL_CMP_CTX_get1_extraCertsIn() returns a pointer to a duplicate of the list
|
||||
of X.509 certificates contained in the extraCerts field of the last received
|
||||
response message (except for pollRep and PKIConf), or
|
||||
an empty stack if no extraCerts have been received in the current transaction.
|
||||
|
||||
OSSL_CMP_CTX_set1_transactionID() sets the given transaction ID in the given
|
||||
OSSL_CMP_CTX structure.
|
||||
|
Loading…
x
Reference in New Issue
Block a user