return pt->check_purpose(pt, x, non_leaf);
}
+/* resets to default (any) purpose if purpose == X509_PURPOSE_DEFAULT_ANY (0) */
int X509_PURPOSE_set(int *p, int purpose)
{
- if (X509_PURPOSE_get_by_id(purpose) == -1) {
+ if (purpose != X509_PURPOSE_DEFAULT_ANY && X509_PURPOSE_get_by_id(purpose) == -1) {
ERR_raise(ERR_LIB_X509V3, X509V3_R_INVALID_PURPOSE);
return 0;
}
}
/* check_purpose() makes the callback as needed */
- if (purpose > 0 && !check_purpose(ctx, x, purpose, i, must_be_ca))
+ if (purpose >= X509_PURPOSE_MIN && !check_purpose(ctx, x, purpose, i, must_be_ca))
return 0;
/* Check path length */
CB_FAIL_IF(i > 1 && x->ex_pathlen != -1
return 1;
}
+/* resets to default (any) purpose if |purpose| == X509_PURPOSE_DEFAULT_ANY */
int X509_VERIFY_PARAM_set_purpose(X509_VERIFY_PARAM *param, int purpose)
{
return X509_PURPOSE_set(¶m->purpose, purpose);
X509_VERIFY_PARAM_set_purpose() sets the verification purpose in B<param>
to B<purpose>. This determines the acceptable purpose of the certificate
chain, for example B<X509_PURPOSE_SSL_CLIENT>.
-The purpose requirement is cleared if B<purpose> is 0.
+The purpose requirement is cleared if B<purpose> is X509_PURPOSE_DEFAULT_ANY.
X509_VERIFY_PARAM_set_trust() sets the trust setting in B<param> to
B<trust>.
-}
+# define X509_PURPOSE_DEFAULT_ANY 0
# define X509_PURPOSE_SSL_CLIENT 1
# define X509_PURPOSE_SSL_SERVER 2
# define X509_PURPOSE_NS_SSL_SERVER 3