summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/man/X509_check_host.3
diff options
context:
space:
mode:
authorschwarze <>2016-12-05 15:56:46 +0000
committerschwarze <>2016-12-05 15:56:46 +0000
commit775cd7a13393b0cf5d8e3feb6200f9cbd3f86267 (patch)
treeca928ee81671abd3d9127c62cba44966ae5dfc94 /src/lib/libcrypto/man/X509_check_host.3
parent0cc9c59f1ff316b0df69667021b1dd558b0be9e8 (diff)
downloadopenbsd-775cd7a13393b0cf5d8e3feb6200f9cbd3f86267.tar.gz
openbsd-775cd7a13393b0cf5d8e3feb6200f9cbd3f86267.tar.bz2
openbsd-775cd7a13393b0cf5d8e3feb6200f9cbd3f86267.zip
import three X509_check_*(3) manuals from OpenSSL
Diffstat (limited to 'src/lib/libcrypto/man/X509_check_host.3')
-rw-r--r--src/lib/libcrypto/man/X509_check_host.3234
1 files changed, 234 insertions, 0 deletions
diff --git a/src/lib/libcrypto/man/X509_check_host.3 b/src/lib/libcrypto/man/X509_check_host.3
new file mode 100644
index 0000000000..1e6a44ffe1
--- /dev/null
+++ b/src/lib/libcrypto/man/X509_check_host.3
@@ -0,0 +1,234 @@
1.\" $OpenBSD: X509_check_host.3,v 1.1 2016/12/05 15:56:46 schwarze Exp $
2.\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\"
4.\" This file was written by Florian Weimer <fweimer@redhat.com> and
5.\" Viktor Dukhovni <openssl-users@dukhovni.org>.
6.\" Copyright (c) 2012, 2014, 2015, 2016 The OpenSSL Project. All rights reserved.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\"
12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer.
14.\"
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\" notice, this list of conditions and the following disclaimer in
17.\" the documentation and/or other materials provided with the
18.\" distribution.
19.\"
20.\" 3. All advertising materials mentioning features or use of this
21.\" software must display the following acknowledgment:
22.\" "This product includes software developed by the OpenSSL Project
23.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24.\"
25.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26.\" endorse or promote products derived from this software without
27.\" prior written permission. For written permission, please contact
28.\" openssl-core@openssl.org.
29.\"
30.\" 5. Products derived from this software may not be called "OpenSSL"
31.\" nor may "OpenSSL" appear in their names without prior written
32.\" permission of the OpenSSL Project.
33.\"
34.\" 6. Redistributions of any form whatsoever must retain the following
35.\" acknowledgment:
36.\" "This product includes software developed by the OpenSSL Project
37.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38.\"
39.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\"
52.Dd $Mdocdate: December 5 2016 $
53.Dt X509_CHECK_HOST 3
54.Os
55.Sh NAME
56.Nm X509_check_host ,
57.Nm X509_check_email ,
58.Nm X509_check_ip ,
59.Nm X509_check_ip_asc
60.Nd X.509 certificate matching
61.Sh SYNOPSIS
62.In openssl/x509v3.h
63.Ft int
64.Fo X509_check_host
65.Fa "X509 *x"
66.Fa "const char *name"
67.Fa "size_t namelen"
68.Fa "unsigned int flags"
69.Fa "char **peername"
70.Fc
71.Ft int
72.Fo X509_check_email
73.Fa "X509 *x"
74.Fa "const char *address"
75.Fa "size_t addresslen"
76.Fa "unsigned int flags"
77.Fc
78.Ft int
79.Fo X509_check_ip
80.Fa "X509 *x"
81.Fa "const unsigned char *address"
82.Fa "size_t addresslen"
83.Fa "unsigned int flags"
84.Fc
85.Ft int
86.Fo X509_check_ip_asc
87.Fa "X509 *x"
88.Fa "const char *address"
89.Fa "unsigned int flags"
90.Fc
91.Sh DESCRIPTION
92The certificate matching functions are used to check whether a
93certificate matches a given host name, email address, or IP address.
94The validity of the certificate and its trust level has to be checked by
95other means.
96.Pp
97.Fn X509_check_host
98checks if the certificate Subject Alternative Name (SAN) or Subject
99CommonName (CN) matches the specified host name, which must be encoded
100in the preferred name syntax described in section 3.5 of RFC 1034.
101By default, wildcards are supported and they match only in the
102left-most label; but they may match part of that label with an
103explicit prefix or suffix.
104For example, by default, the host
105.Fa name
106.Qq www.example.com
107would match a certificate with a SAN or CN value of
108.Qq *.example.com ,
109.Qq w*.example.com
110or
111.Qq *w.example.com .
112.Pp
113Per section 6.4.2 of RFC 6125,
114.Fa name
115values representing international domain names must be given in A-label
116form.
117The
118.Fa namelen
119argument must be the number of characters in the name string or zero, in
120which case the length is calculated with
121.Fn strlen name .
122When
123.Fa name
124starts with a dot (e.g.\&
125.Qq .example.com ) ,
126it will be matched by a certificate valid for any sub-domain of
127.Fa name ; see also
128.Fa X509_CHECK_FLAG_SINGLE_LABEL_SUBDOMAINS
129below.
130.Pp
131When the certificate is matched and
132.Fa peername
133is not
134.Dv NULL ,
135a pointer to a copy of the matching SAN or CN from the peer
136certificate is stored at the address passed in
137.Fa peername .
138The application is responsible for freeing the peername via
139.Xr free 3
140when it is no longer needed.
141.Pp
142.Fn X509_check_email
143checks if the certificate matches the specified email
144.Fa address .
145Only the mailbox syntax of RFC 822 is supported, comments are not
146allowed, and no attempt is made to normalize quoted characters.
147The
148.Fa addresslen
149argument must be the number of characters in the address string or zero
150in which case the length is calculated with
151.Fn strlen address .
152.Pp
153.Fn X509_check_ip
154checks if the certificate matches a specified IPv4 or IPv6 address.
155The
156.Fa address
157array is in binary format, in network byte order.
158The length is either 4 (IPv4) or 16 (IPv6).
159Only explicitly marked addresses in the certificates are considered;
160IP addresses stored in DNS names and Common Names are ignored.
161.Pp
162.Fn X509_check_ip_asc
163is similar, except that the NUL-terminated string
164.Fa address
165is first converted to the internal representation.
166.Pp
167The
168.Fa flags
169argument is usually 0, but it can be the bitwise OR of the following
170flags.
171.Pp
172The
173.Dv X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT
174flag causes the function to consider the subject DN even if the
175certificate contains at least one subject alternative name of the right
176type (DNS name or email address as appropriate); the default is to
177ignore the subject DN when at least one corresponding subject
178alternative names is present.
179.Pp
180The remaining flags are only meaningful for
181.Fn X509_check_host .
182.Pp
183The
184.Dv X509_CHECK_FLAG_NO_WILDCARDS
185flag disables wildcard expansion.
186.Pp
187The
188.Dv X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS
189flag suppresses support for
190.Qq *
191as a wildcard pattern in labels that have a
192prefix or suffix, such as
193.Qq www*
194or
195.Qq *www .
196.Pp
197The
198.Dv X509_CHECK_FLAG_MULTI_LABEL_WILDCARDS
199flag allows a
200.Qq *
201that constitutes the complete label of a DNS name (e.g.\&
202.Qq *.example.com )
203to match more than one label in
204.Fa name .
205.Pp
206The
207.Dv X509_CHECK_FLAG_SINGLE_LABEL_SUBDOMAINS
208flag restricts
209.Fa name
210values which start with
211.Qq \&. ,
212that would otherwise match any sub-domain in the peer certificate,
213to only match direct child sub-domains.
214Thus, for instance, with this flag set a
215.Fa name
216of
217.Qq .example.com
218would match a peer certificate with a DNS name of
219.Qq www.example.com ,
220but would not match a peer certificate with a DNS name of
221.Qq www.sub.example.com .
222.Sh RETURN VALUES
223The functions return 1 for a successful match, 0 for a failed match and
224-1 for an internal error: typically a memory allocation failure or an
225ASN.1 decoding error.
226.Pp
227All functions can also return -2 if the input is malformed.
228For example,
229.Fn X509_check_host
230returns -2 if the provided
231.Fa name
232contains embedded NUL bytes.
233.Sh HISTORY
234These functions were added in OpenSSL 1.0.2.