Commit e417070c authored by Rich Salz's avatar Rich Salz
Browse files

Add some accessor API's



GH1098: Add X509_get_pathlen() (and a test)
GH1097:  Add SSL_is_dtls() function.

Documented.

Reviewed-by: default avatarMatt Caswell <matt@openssl.org>
parent 01d0e241
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -84,6 +84,7 @@ Makefile
/test/fips_test_suite
/test/ssltest_old
/test/x509aux
/test/v3ext
*.so*
*.dylib*
*.dll*
+9 −0
Original line number Diff line number Diff line
@@ -838,3 +838,12 @@ const ASN1_OCTET_STRING *X509_get0_subject_key_id(X509 *x)
    X509_check_purpose(x, -1, -1);
    return x->skid;
}

long X509_get_pathlen(X509 *x)
{
    /* Called for side effect of caching extensions */
    if (X509_check_purpose(x, -1, -1) != 1
            || (x->ex_flags & EXFLAG_BCONS) == 0)
        return -1;
    return x->ex_pathlen;
}
+15 −2
Original line number Diff line number Diff line
@@ -2,13 +2,15 @@

=head1 NAME

X509_get_pathlen,
X509_get_extension_flags, X509_get_key_usage, X509_get_extended_key_usage -
retrieve certificate extension flags
retrieve certificate extension data

=head1 SYNOPSIS

   #include <openssl/x509v3.h>

   long X509_get_pathlen(X509 *x);
   uint32_t X509_get_extension_flags(X509 *x);
   uint32_t X509_get_key_usage(X509 *x);
   uint32_t X509_get_extended_key_usage(X509 *x);
@@ -16,7 +18,11 @@ retrieve certificate extension flags

=head1 DESCRIPTION

These functions retrieve flags related to commonly used certificate extensions.
These functions retrieve information related to commonly used certificate extensions.

X509_get_pathlen() retrieves the path length extension from a certificate.
This extension is used to limit the length of a cert chain that may be
issued from that CA.

X509_get_extension_flags() retrieves general information about a certificate,
it will return one or more of the following flags ored together.
@@ -115,6 +121,9 @@ X509_get_ext_d2i().

=head1 RETURN VALUE

X509_get_pathlen() returns the path length value, or -1 if the extension
is not present.

X509_get_extension_flags(), X509_get_key_usage() and
X509_get_extended_key_usage() return sets of flags corresponding to the
certificate extension values.
@@ -127,6 +136,10 @@ is absent or an error occurred during parsing.

L<X509_check_purpose(3)>

=head1 HISTORY

X509_get_pathlen() was added in OpenSSL 1.1.0.

=head1 COPYRIGHT

Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
+10 −2
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@

=head1 NAME

SSL_get_version - get the protocol version of a connection
SSL_get_version, SSL_is_dtls - get the protocol information of a connection

=head1 SYNOPSIS

@@ -10,14 +10,18 @@ SSL_get_version - get the protocol version of a connection

 const char *SSL_get_version(const SSL *ssl);

 int SSL_is_dtls(const SSL *ssl);

=head1 DESCRIPTION

SSL_get_version() returns the name of the protocol used for the
connection B<ssl>.

SSL_is_dtls() returns one if the connection is using DTLS, zero if not.

=head1 RETURN VALUES

The following strings can be returned:
SSL_get_verison() returns one of the following strings:

=over 4

@@ -47,6 +51,10 @@ This indicates that no version has been set (no connection established).

L<ssl(3)>

=head1 HISTORY

SSL_is_dtls() was added in OpenSSL 1.1.0.

=head1 COPYRIGHT

Copyright 2001-2016 The OpenSSL Project Authors. All Rights Reserved.
+2 −0
Original line number Diff line number Diff line
@@ -520,6 +520,8 @@ fresh handle for each connection.

=item const char *B<SSL_get_cipher>(const SSL *ssl);

=item int B<SSL_is_dtls>(const SSL *ssl);

=item int B<SSL_get_cipher_bits>(const SSL *ssl, int *alg_bits);

=item char *B<SSL_get_cipher_list>(const SSL *ssl, int n);
Loading