mirror of
https://github.com/openssl/openssl.git
synced 2025-01-18 13:44:20 +08:00
x509_vfy.c: Fix various coding style and documentation style nits
Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14127)
This commit is contained in:
parent
93b39c85c9
commit
579262af14
@ -122,7 +122,7 @@ static X509 *lookup_cert_match(X509_STORE_CTX *ctx, X509 *x)
|
||||
/* Look for exact match */
|
||||
for (i = 0; i < sk_X509_num(certs); i++) {
|
||||
xtmp = sk_X509_value(certs, i);
|
||||
if (!X509_cmp(xtmp, x))
|
||||
if (X509_cmp(xtmp, x) == 0)
|
||||
break;
|
||||
xtmp = NULL;
|
||||
}
|
||||
@ -232,7 +232,7 @@ static int verify_chain(X509_STORE_CTX *ctx)
|
||||
#endif
|
||||
|
||||
/* If we get this far evaluate policies */
|
||||
if (ctx->param->flags & X509_V_FLAG_POLICY_CHECK)
|
||||
if ((ctx->param->flags & X509_V_FLAG_POLICY_CHECK) != 0)
|
||||
ok = ctx->check_policy(ctx);
|
||||
return ok;
|
||||
}
|
||||
@ -816,12 +816,13 @@ static int check_trust(X509_STORE_CTX *ctx, int num_untrusted)
|
||||
* the chain is PKIX trusted.
|
||||
*/
|
||||
if (num_untrusted < num) {
|
||||
if (ctx->param->flags & X509_V_FLAG_PARTIAL_CHAIN)
|
||||
if ((ctx->param->flags & X509_V_FLAG_PARTIAL_CHAIN) != 0)
|
||||
goto trusted;
|
||||
return X509_TRUST_UNTRUSTED;
|
||||
}
|
||||
|
||||
if (num_untrusted == num && ctx->param->flags & X509_V_FLAG_PARTIAL_CHAIN) {
|
||||
if (num_untrusted == num
|
||||
&& (ctx->param->flags & X509_V_FLAG_PARTIAL_CHAIN) != 0) {
|
||||
/*
|
||||
* Last-resort call with no new trusted certificates, check the leaf
|
||||
* for a direct trust store match.
|
||||
@ -1744,7 +1745,7 @@ static int internal_verify(X509_STORE_CTX *ctx)
|
||||
*/
|
||||
if (xi != NULL
|
||||
&& (xs != xi
|
||||
|| ((ctx->param->flags & X509_V_FLAG_CHECK_SS_SIGNATURE)
|
||||
|| ((ctx->param->flags & X509_V_FLAG_CHECK_SS_SIGNATURE) != 0
|
||||
&& (xi->ex_flags & EXFLAG_SS) != 0))) {
|
||||
EVP_PKEY *pkey;
|
||||
/*
|
||||
@ -1936,7 +1937,7 @@ int X509_get_pubkey_parameters(EVP_PKEY *pkey, STACK_OF(X509) *chain)
|
||||
EVP_PKEY *ktmp = NULL, *ktmp2;
|
||||
int i, j;
|
||||
|
||||
if ((pkey != NULL) && !EVP_PKEY_missing_parameters(pkey))
|
||||
if (pkey != NULL && !EVP_PKEY_missing_parameters(pkey))
|
||||
return 1;
|
||||
|
||||
for (i = 0; i < sk_X509_num(chain); i++) {
|
||||
@ -2176,7 +2177,6 @@ int X509_STORE_CTX_set_trust(X509_STORE_CTX *ctx, int trust)
|
||||
* application can set: if they aren't set then we use the default of SSL
|
||||
* client/server.
|
||||
*/
|
||||
|
||||
int X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx, int def_purpose,
|
||||
int purpose, int trust)
|
||||
{
|
||||
@ -2958,7 +2958,7 @@ static int build_chain(X509_STORE_CTX *ctx)
|
||||
* and alternate chains are not disabled, try building an alternate chain
|
||||
* if no luck with untrusted first.
|
||||
*/
|
||||
search = (ctx->untrusted != NULL) ? S_DOUNTRUSTED : 0;
|
||||
search = ctx->untrusted != NULL ? S_DOUNTRUSTED : 0;
|
||||
if (DANETLS_HAS_PKIX(dane) || !DANETLS_HAS_DANE(dane)) {
|
||||
if (search == 0 || (ctx->param->flags & X509_V_FLAG_TRUSTED_FIRST) != 0)
|
||||
search |= S_DOTRUSTED;
|
||||
@ -3054,7 +3054,7 @@ static int build_chain(X509_STORE_CTX *ctx)
|
||||
}
|
||||
curr = sk_X509_value(ctx->chain, i - 1);
|
||||
|
||||
ok = depth < num ? 0 : get_issuer(&issuer, ctx, curr);
|
||||
ok = num > depth ? 0 : get_issuer(&issuer, ctx, curr);
|
||||
|
||||
if (ok < 0) {
|
||||
trust = X509_TRUST_REJECTED;
|
||||
@ -3191,7 +3191,7 @@ static int build_chain(X509_STORE_CTX *ctx)
|
||||
if (!ossl_assert(num == ctx->num_untrusted))
|
||||
goto int_err;
|
||||
curr = sk_X509_value(ctx->chain, num - 1);
|
||||
issuer = (self_signed || depth < num) ?
|
||||
issuer = (self_signed || num > depth) ?
|
||||
NULL : find_issuer(ctx, sk_untrusted, curr);
|
||||
if (issuer == NULL) {
|
||||
/*
|
||||
@ -3208,7 +3208,7 @@ static int build_chain(X509_STORE_CTX *ctx)
|
||||
/* Drop this issuer from future consideration */
|
||||
(void)sk_X509_delete_ptr(sk_untrusted, issuer);
|
||||
|
||||
if (!X509_add_cert(ctx->chain, issuer, X509_ADD_FLAG_UP_REF))
|
||||
if (!X509_add_cert(ctx->chain, issuer, X509_ADD_FLAG_UP_REF))
|
||||
goto int_err;
|
||||
|
||||
++ctx->num_untrusted;
|
||||
|
@ -34,23 +34,23 @@ an error or in a verification callback to determine the nature of an error.
|
||||
X509_STORE_CTX_get_error() returns the error code of B<ctx>, see
|
||||
the B<ERROR CODES> section for a full description of all error codes.
|
||||
|
||||
X509_STORE_CTX_set_error() sets the error code of B<ctx> to B<s>. For example
|
||||
X509_STORE_CTX_set_error() sets the error code of I<ctx> to I<s>. For example
|
||||
it might be used in a verification callback to set an error based on additional
|
||||
checks.
|
||||
|
||||
X509_STORE_CTX_get_error_depth() returns the B<depth> of the error. This is a
|
||||
X509_STORE_CTX_get_error_depth() returns the I<depth> of the error. This is a
|
||||
nonnegative integer representing where in the certificate chain the error
|
||||
occurred. If it is zero it occurred in the end entity certificate, one if
|
||||
it is the certificate which signed the end entity certificate and so on.
|
||||
|
||||
X509_STORE_CTX_set_error_depth() sets the error B<depth>.
|
||||
X509_STORE_CTX_set_error_depth() sets the error I<depth>.
|
||||
This can be used in combination with X509_STORE_CTX_set_error() to set the
|
||||
depth at which an error condition was detected.
|
||||
|
||||
X509_STORE_CTX_get_current_cert() returns the certificate in B<ctx> which
|
||||
caused the error or B<NULL> if no certificate is relevant.
|
||||
X509_STORE_CTX_get_current_cert() returns the certificate in I<ctx> which
|
||||
caused the error or NULL if no certificate is relevant.
|
||||
|
||||
X509_STORE_CTX_set_current_cert() sets the certificate B<x> in B<ctx> which
|
||||
X509_STORE_CTX_set_current_cert() sets the certificate I<x> in I<ctx> which
|
||||
caused the error.
|
||||
This value is not intended to remain valid for very long, and remains owned by
|
||||
the caller.
|
||||
@ -63,17 +63,17 @@ Once such a I<saved> certificate is no longer needed it can be freed with
|
||||
L<X509_free(3)>.
|
||||
|
||||
X509_STORE_CTX_get0_cert() retrieves an internal pointer to the
|
||||
certificate being verified by the B<ctx>.
|
||||
certificate being verified by the I<ctx>.
|
||||
|
||||
X509_STORE_CTX_get1_chain() returns a complete validate chain if a previous
|
||||
verification is successful. Otherwise the returned chain may be incomplete or
|
||||
invalid. The returned chain persists after the B<ctx> structure is freed,
|
||||
when it is no longer needed it should be free up using:
|
||||
invalid. The returned chain persists after the I<ctx> structure is freed.
|
||||
When it is no longer needed it should be free up using:
|
||||
|
||||
sk_X509_pop_free(chain, X509_free);
|
||||
|
||||
X509_verify_cert_error_string() returns a human readable error string for
|
||||
verification error B<n>.
|
||||
verification error I<n>.
|
||||
|
||||
=head1 RETURN VALUES
|
||||
|
||||
@ -82,10 +82,10 @@ X509_STORE_CTX_get_error() returns B<X509_V_OK> or an error code.
|
||||
X509_STORE_CTX_get_error_depth() returns a nonnegative error depth.
|
||||
|
||||
X509_STORE_CTX_get_current_cert() returns the certificate which caused the
|
||||
error or B<NULL> if no certificate is relevant to the error.
|
||||
error or NULL if no certificate is relevant to the error.
|
||||
|
||||
X509_verify_cert_error_string() returns a human readable error string for
|
||||
verification error B<n>.
|
||||
verification error I<n>.
|
||||
|
||||
=head1 ERROR CODES
|
||||
|
||||
@ -163,12 +163,12 @@ The CRL has expired.
|
||||
=item B<X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD:
|
||||
format error in certificate's notBefore field>
|
||||
|
||||
The certificate B<notBefore> field contains an invalid time.
|
||||
The certificate C<notBefore> field contains an invalid time.
|
||||
|
||||
=item B<X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD:
|
||||
format error in certificate's notAfter field>
|
||||
|
||||
The certificate B<notAfter> field contains an invalid time.
|
||||
The certificate C<notAfter> field contains an invalid time.
|
||||
|
||||
=item B<X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD:
|
||||
format error in CRL's lastUpdate field>
|
||||
@ -178,7 +178,7 @@ The CRL B<lastUpdate> field contains an invalid time.
|
||||
=item B<X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD:
|
||||
format error in CRL's nextUpdate field>
|
||||
|
||||
The CRL B<nextUpdate> field contains an invalid time.
|
||||
The CRL C<nextUpdate> field contains an invalid time.
|
||||
|
||||
=item B<X509_V_ERR_OUT_OF_MEM: out of memory>
|
||||
|
||||
@ -261,7 +261,7 @@ Not used as of OpenSSL 1.1.0.
|
||||
=item B<X509_V_ERR_KEYUSAGE_NO_CERTSIGN:
|
||||
key usage does not include certificate signing>
|
||||
|
||||
The current candidate issuer certificate was rejected because its B<keyUsage>
|
||||
The current candidate issuer certificate was rejected because its C<keyUsage>
|
||||
extension does not permit certificate signing.
|
||||
Not used as of OpenSSL 1.1.0.
|
||||
|
||||
@ -359,7 +359,8 @@ certificates.
|
||||
|
||||
=item B<X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED: proxy certificates not allowed, please set the appropriate flag>
|
||||
|
||||
Proxy certificates not allowed unless the B<-allow_proxy_certs> option is used.
|
||||
Proxy certificates not allowed unless the B<X509_V_FLAG_ALLOW_PROXY_CERTS> flag
|
||||
is set.
|
||||
|
||||
=item B<X509_V_ERR_UNNESTED_RESOURCE: RFC 3779 resource not subset of parent's resources>
|
||||
|
||||
@ -449,7 +450,7 @@ The above functions should be used instead of directly referencing the fields
|
||||
in the B<X509_VERIFY_CTX> structure.
|
||||
|
||||
In versions of OpenSSL before 1.0 the current certificate returned by
|
||||
X509_STORE_CTX_get_current_cert() was never B<NULL>. Applications should
|
||||
X509_STORE_CTX_get_current_cert() was never NULL. Applications should
|
||||
check the return value before printing out any debugging information relating
|
||||
to the current certificate.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user