* convert an X509_NAME to an RFC 2253 formatted string, optionally truncated * to maxlen characters (specify a maxlen of 0 for no length limit) */
| 233 | * to maxlen characters (specify a maxlen of 0 for no length limit) |
| 234 | */ |
| 235 | char *modssl_X509_NAME_to_string(apr_pool_t *p, const X509_NAME *dn, int maxlen) |
| 236 | { |
| 237 | char *result = NULL; |
| 238 | BIO *bio; |
| 239 | int len; |
| 240 | |
| 241 | if ((bio = BIO_new(BIO_s_mem())) == NULL) |
| 242 | return NULL; |
| 243 | X509_NAME_print_ex(bio, dn, 0, XN_FLAG_RFC2253); |
| 244 | len = BIO_pending(bio); |
| 245 | if (len > 0) { |
| 246 | result = apr_palloc(p, (maxlen > 0) ? maxlen+1 : len+1); |
| 247 | if (maxlen > 0 && maxlen < len) { |
| 248 | len = BIO_read(bio, result, maxlen); |
| 249 | if (maxlen > 2) { |
| 250 | /* insert trailing ellipsis if there's enough space */ |
| 251 | apr_snprintf(result + maxlen - 3, 4, "..."); |
| 252 | } |
| 253 | } else { |
| 254 | len = BIO_read(bio, result, len); |
| 255 | } |
| 256 | result[len] = NUL; |
| 257 | } |
| 258 | BIO_free(bio); |
| 259 | |
| 260 | return result; |
| 261 | } |
| 262 | |
| 263 | static void parse_otherName_value(apr_pool_t *p, ASN1_TYPE *value, |
| 264 | const char *onf, apr_array_header_t **entries) |
no outgoing calls
no test coverage detected