void gnutls_x509_name_constraints_deinit(gnutls_x509_name_constraints_t nc);
int gnutls_x509_crt_get_name_constraints(gnutls_x509_crt_t crt,
gnutls_x509_name_constraints_t nc,
+ unsigned int append,
unsigned int *critical);
int gnutls_x509_name_constraints_add_permitted(gnutls_x509_name_constraints_t nc,
gnutls_x509_subject_alt_name_t type,
* gnutls_x509_crt_get_name_constraints:
* @crt: should contain a #gnutls_x509_crt_t structure
* @nc: The nameconstraints intermediate structure
+ * @append: whether the constraints from the certificate will be set or appended
* @critical: the extension status
*
* This function will return an intermediate structure containing
* structure can be used in combination with gnutls_x509_name_constraints_check()
* to verify whether a server's name is in accordance with the constraints.
*
+ * When the @append flag is set to 1, then if the @nc structure is empty
+ * this function will behave identically as if the flag was not set.
+ * Otherwise if there are elements in the @nc structure then only the
+ * excluded constraints will be appended to the constraints.
+ *
* Note that @nc must be initialized prior to calling this function.
*
* Returns: On success, %GNUTLS_E_SUCCESS (0) is returned, %GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE
**/
int gnutls_x509_crt_get_name_constraints(gnutls_x509_crt_t crt,
gnutls_x509_name_constraints_t nc,
+ unsigned int append,
unsigned int *critical)
{
int result, ret;
goto cleanup;
}
- ret = extract_name_constraints(c2, "permittedSubtrees", &nc->permitted);
- if (ret < 0) {
- gnutls_assert();
- goto cleanup;
+ if (append == 0 || (nc->permitted == NULL && nc->excluded == NULL)) {
+ ret = extract_name_constraints(c2, "permittedSubtrees", &nc->permitted);
+ if (ret < 0) {
+ gnutls_assert();
+ goto cleanup;
+ }
}
ret = extract_name_constraints(c2, "excludedSubtrees", &nc->excluded);