[rs-commit] r106 - in /redwax-tool/trunk: redwax_openssl.c redwax_util.c redwax_util.h
rs-commit at redwax.eu
rs-commit at redwax.eu
Thu Dec 2 13:01:01 CET 2021
Author: minfrin at redwax.eu
Date: Thu Dec 2 13:01:00 2021
New Revision: 106
Log:
Add certificate policies.
Modified:
redwax-tool/trunk/redwax_openssl.c
redwax-tool/trunk/redwax_util.c
redwax-tool/trunk/redwax_util.h
Modified: redwax-tool/trunk/redwax_openssl.c
==============================================================================
--- redwax-tool/trunk/redwax_openssl.c (original)
+++ redwax-tool/trunk/redwax_openssl.c Thu Dec 2 13:01:00 2021
@@ -3118,6 +3118,172 @@
break;
}
+ case NID_certificate_policies: {
+
+ STACK_OF(POLICYINFO) *pol = X509V3_EXT_d2i(ex);
+
+ int i, j, k;
+
+ if (sk_POLICYINFO_num(pol)) {
+
+ redwax_metadata_push_array(m, "Policies", 0);
+
+ for (i = 0; i < sk_POLICYINFO_num(pol); i++) {
+
+ POLICYINFO *pinfo;
+
+ BIO *bio;
+ char *buf = NULL;
+ int len = 0;
+
+ pinfo = sk_POLICYINFO_value(pol, i);
+
+ if (pinfo->policyid) {
+
+ redwax_metadata_push_object(m, "Policy", 0);
+
+ if ((bio = BIO_new(BIO_s_mem())) == NULL) {
+ return APR_ENOMEM;
+ }
+
+ i2a_ASN1_OBJECT(bio, pinfo->policyid);
+
+ len = BIO_get_mem_data(bio, &buf);
+
+ redwax_metadata_add_string(m, "ID",
+ apr_psprintf(m->pool, "%.*s", len, buf));
+
+ BIO_free(bio);
+
+ if (pinfo->qualifiers
+ && sk_POLICYQUALINFO_num(pinfo->qualifiers)) {
+
+ redwax_metadata_push_array(m, "Qualifiers", 0);
+
+ for (j = 0;
+ j < sk_POLICYQUALINFO_num(pinfo->qualifiers);
+ j++) {
+
+ POLICYQUALINFO *qualinfo;
+
+ redwax_metadata_push_object(m, "Qualifier", 0);
+
+ qualinfo = sk_POLICYQUALINFO_value(
+ pinfo->qualifiers, j);
+
+ switch (OBJ_obj2nid(qualinfo->pqualid)) {
+ case NID_id_qt_cps: {
+
+ redwax_metadata_add_string(m, "CPS",
+ apr_psprintf(m->pool, "%.*s",
+ qualinfo->d.cpsuri->length,
+ qualinfo->d.cpsuri->data));
+
+ break;
+
+ }
+ case NID_id_qt_unotice: {
+
+ USERNOTICE *notice = qualinfo->d.usernotice;
+
+ redwax_metadata_push_object(m, "User Notice",
+ 0);
+
+ if (notice->noticeref) {
+
+ NOTICEREF *ref;
+
+ ref = notice->noticeref;
+
+ if (ref->organization
+ && ref->organization->data) {
+
+ redwax_metadata_add_string(m,
+ "Organization",
+ apr_psprintf(m->pool, "%.*s",
+ ref->organization->length,
+ ref->organization->data));
+
+ }
+
+ if (sk_ASN1_INTEGER_num(ref->noticenos)) {
+
+ redwax_metadata_push_array(m, "Numbers",
+ 0);
+
+ for (k = 0;
+ k
+ < sk_ASN1_INTEGER_num(
+ ref->noticenos);
+ k++) {
+
+ ASN1_INTEGER *num;
+
+ num = sk_ASN1_INTEGER_value(
+ ref->noticenos, k);
+
+ if (num) {
+
+ char *tmp;
+
+ tmp = i2s_ASN1_INTEGER(NULL,
+ num);
+ if (tmp) {
+
+ redwax_metadata_add_number(
+ m, "Number", tmp,
+ strlen(tmp));
+
+ OPENSSL_free(tmp);
+ }
+
+ } else {
+ redwax_metadata_add_null(m,
+ "Number");
+ }
+ }
+
+ redwax_metadata_pop_array(m);
+ }
+ }
+
+ if (notice->exptext) {
+
+ redwax_metadata_add_string(m,
+ "ExplicitText",
+ apr_psprintf(m->pool, "%.*s",
+ notice->exptext->length,
+ notice->exptext->data));
+ }
+
+ redwax_metadata_pop_object(m);
+
+ break;
+ }
+ default: {
+
+ redwax_print_error(r,
+ "metadata-out: unsupported Policy qualifier, ignoring\n");
+
+ break;
+ }
+ }
+
+ redwax_metadata_pop_object(m);
+ }
+
+ redwax_metadata_pop_array(m);
+ }
+ redwax_metadata_pop_object(m);
+ }
+
+ }
+
+ redwax_metadata_pop_array(m);
+ }
+
+ break;
+ }
default:
/*
Modified: redwax-tool/trunk/redwax_util.c
==============================================================================
--- redwax-tool/trunk/redwax_util.c (original)
+++ redwax-tool/trunk/redwax_util.c Thu Dec 2 13:01:00 2021
@@ -1840,3 +1840,8 @@
return redwax_metadata_add_number(m, key, v, vlen);
}
+
+apr_status_t redwax_metadata_add_null(redwax_metadata_t *m, const char *key)
+{
+ return redwax_metadata_add_string(m, key, NULL);
+}
Modified: redwax-tool/trunk/redwax_util.h
==============================================================================
--- redwax-tool/trunk/redwax_util.h (original)
+++ redwax-tool/trunk/redwax_util.h Thu Dec 2 13:01:00 2021
@@ -137,4 +137,6 @@
apr_status_t redwax_metadata_add_boolean(redwax_metadata_t *m, const char *key, int val);
+apr_status_t redwax_metadata_add_null(redwax_metadata_t *m, const char *key);
+
#endif
More information about the rs-commit
mailing list