src/ssl_sock.c
static int
ssl_sock_get_dn_oneline(X509_NAME *a, struct chunk *out)
{
	X509_NAME_ENTRY *ne;
	int i, n, ln;
	int l = 0;
	const char *s;
	char *p;
	char tmp[128];

	out->len = 0;
	p = out->str;
	for (i = 0; i < sk_X509_NAME_ENTRY_num(a->entries); i++) {
		ne = sk_X509_NAME_ENTRY_value(a->entries, i);
		n = OBJ_obj2nid(ne->object);
		if ((n == NID_undef) || ((s = OBJ_nid2sn(n)) == NULL)) {
			i2t_ASN1_OBJECT(tmp, sizeof(tmp), ne->object);
			s = tmp;
		}
		ln = strlen(s);

		l += 1 + ln + 1 + ne->value->length;
		if (l > out->size)
			return -1;
		out->len = l;

		*(p++)='/';
		memcpy(p, s, ln);
		p += ln;
		*(p++)='=';
		memcpy(p, ne->value->data, ne->value->length);
		p += ne->value->length;
	}

	if (!out->len)
		return 0;

	return 1;
}
/* Extract and format full DN from a X509_NAME and copy result into a chunk
 * Returns 1 if dn entries exits, 0 if no dn entry found or -1 if output is not large enough.
 */
Extract and format full DN from a X509_NAME and copy result into a chunk
Returns 1 if dn entries exits, 0 if no dn entry found or -1 if output is not large enough.
Extract and format full DN from a X509_NAME and copy result into a chunk Returns 1 if dn entries exits 0 if no dn entry found or - 1 if output is not large enough .
static int
ssl_sock_get_dn_oneline(X509_NAME *a, struct chunk *out)
{
	X509_NAME_ENTRY *ne;
	int i, n, ln;
	int l = 0;
	const char *s;
	char *p;
	char tmp[128];
	out->len = 0;
	p = out->str;
	for (i = 0; i < sk_X509_NAME_ENTRY_num(a->entries); i++) {
		ne = sk_X509_NAME_ENTRY_value(a->entries, i);
		n = OBJ_obj2nid(ne->object);
		if ((n == NID_undef) || ((s = OBJ_nid2sn(n)) == NULL)) {
			i2t_ASN1_OBJECT(tmp, sizeof(tmp), ne->object);
			s = tmp;
		}
		ln = strlen(s);
		l += 1 + ln + 1 + ne->value->length;
		if (l > out->size)
			return -1;
		out->len = l;
		*(p++)='/';
		memcpy(p, s, ln);
		p += ln;
		*(p++)='=';
		memcpy(p, ne->value->data, ne->value->length);
		p += ne->value->length;
	}
	if (!out->len)
		return 0;
	return 1;
}
static int ssl_sock_get_dn_oneline ( X509_NAME * a , struct chunk * out ) { X509_NAME_ENTRY * ne ; int i , n , ln ; int l = 0 ; const char * s ; char * p ; char tmp [ 128 ] ; out -> len = 0 ; p = out -> str ; for ( i = 0 ; i < sk_X509_NAME_ENTRY_num ( a -> entries ) ; i ++ ) { ne = sk_X509_NAME_ENTRY_value ( a -> entries , i ) ; n = OBJ_obj2nid ( ne -> object ) ; if ( ( n == NID_undef ) || ( ( s = OBJ_nid2sn ( n ) ) == NULL ) ) { i2t_ASN1_OBJECT ( tmp , sizeof ( tmp ) , ne -> object ) ; s = tmp ; } ln = strlen ( s ) ; l += 1 + ln + 1 + ne -> value -> length ; if ( l > out -> size ) return -1 ; out -> len = l ; * ( p ++ ) = ' ' ; memcpy ( p , s , ln ) ; p += ln ; * ( p ++ ) = ' ' ; memcpy ( p , ne -> value -> data , ne -> value -> length ) ; p += ne -> value -> length ; } if ( ! out -> len ) return 0 ; return 1 ; }
Extract and format full DN from a X509_NAME and copy result into a chunk
 Returns 1 if dn entries exits, 0 if no dn entry found or -1 if output is not large enough.
Extract and format full DN from a X509_NAME and copy result into a chunk Returns 1 if dn entries exits 0 if no dn entry found or - 1 if output is not large enough .