summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschwarze <>2020-09-17 07:56:38 +0000
committerschwarze <>2020-09-17 07:56:38 +0000
commiteca320a8712112c5711439902e616353d0069121 (patch)
treecf305c21448150dd3afdc2172690277617a09c68
parent615363fd933cf5613a0c1380020975122fa025a8 (diff)
downloadopenbsd-eca320a8712112c5711439902e616353d0069121.tar.gz
openbsd-eca320a8712112c5711439902e616353d0069121.tar.bz2
openbsd-eca320a8712112c5711439902e616353d0069121.zip
Import a manual page for SSL_set1_host(3), which we already have since 6.5,
and for SSL_get0_peername(3), which tb@ will soon make available, from the OpenSSL 1.1.1 branch, which is still under a free license, deleting parts that do not apply to OpenBSD, and tweaked by me. Several improvements and OK by tb@.
-rw-r--r--src/lib/libssl/man/SSL_set1_host.3155
1 files changed, 155 insertions, 0 deletions
diff --git a/src/lib/libssl/man/SSL_set1_host.3 b/src/lib/libssl/man/SSL_set1_host.3
new file mode 100644
index 0000000000..29623498f5
--- /dev/null
+++ b/src/lib/libssl/man/SSL_set1_host.3
@@ -0,0 +1,155 @@
1.\" $OpenBSD: SSL_set1_host.3,v 1.1 2020/09/17 07:56:38 schwarze Exp $
2.\" selective merge up to: OpenSSL 6328d367 Jul 4 21:58:30 2020 +0200
3.\"
4.\" This file was written by Viktor Dukhovni <viktor@openssl.org>
5.\" Copyright (c) 2015 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: September 17 2020 $
52.Dt SSL_SET1_HOST 3
53.Os
54.Sh NAME
55.Nm SSL_set1_host ,
56.Nm SSL_get0_peername
57.Nd SSL server verification parameters
58.Sh SYNOPSIS
59.In openssl/ssl.h
60.Ft int
61.Fo SSL_set1_host
62.Fa "SSL *ssl"
63.Fa "const char *hostname"
64.Fc
65.Ft const char *
66.Fo SSL_get0_peername
67.Fa "SSL *ssl"
68.Fc
69.Sh DESCRIPTION
70.Fn SSL_set1_host
71configures a server hostname check in the
72.Fa ssl
73client, setting the expected DNS hostname to
74.Fa hostname
75and clearing any previously specified hostname.
76If
77.Fa hostname
78is
79.Dv NULL
80or the empty string, name checks are not performed on the peer certificate.
81If a nonempty
82.Fa hostname
83is specified, certificate verification automatically checks the peer
84hostname via
85.Xr X509_check_host 3
86with
87.Fa flags
88set to 0.
89.Pp
90.Fn SSL_get0_peername
91returns the DNS hostname or subject CommonName from the peer certificate
92that matched one of the reference identifiers.
93Unless wildcard matching is disabled, the name matched in the peer
94certificate may be a wildcard name.
95A reference identifier starting with
96.Sq \&.
97indicates a parent domain prefix rather than a fixed name.
98In this case, the matched peername may be a sub-domain
99of the reference identifier.
100The returned string is owned by the library and is no longer valid
101once the associated
102.Fa ssl
103object is cleared or freed, or if a renegotiation takes place.
104Applications must not free the return value.
105.Pp
106SSL clients are advised to use these functions in preference to
107explicitly calling
108.Xr X509_check_host 3 .
109.Sh RETURN VALUES
110.Fn SSL_set1_host
111returns 1 for success or 0 for failure.
112.Pp
113.Fn SSL_get0_peername
114returns the matched peername or
115.Dv NULL
116if peername verification is not applicable
117or no trusted peername was matched.
118Use
119.Xr SSL_get_verify_result 3
120to determine whether verification succeeded.
121.Sh EXAMPLES
122The calls below check the hostname.
123Wildcards are supported, but they must match the entire label.
124The actual name matched in the certificate (which might be a wildcard)
125is retrieved, and must be copied by the application if it is to be
126retained beyond the lifetime of the SSL connection.
127.Bd -literal
128if (!SSL_set1_host(ssl, "smtp.example.com"))
129 /* error */
130
131/* XXX: Perform SSL_connect() handshake and handle errors here */
132
133if (SSL_get_verify_result(ssl) == X509_V_OK) {
134 const char *peername = SSL_get0_peername(ssl);
135
136 if (peername != NULL)
137 /* Name checks were in scope and matched the peername */
138}
139.Ed
140.Sh SEE ALSO
141.Xr ssl 3 ,
142.Xr SSL_CTX_set_verify 3 ,
143.Xr SSL_get_peer_certificate 3 ,
144.Xr SSL_get_verify_result 3 ,
145.Xr X509_check_host 3 ,
146.Xr X509_VERIFY_PARAM_set1_host 3
147.Sh HISTORY
148Both functions first appeared in OpenSSL 1.1.0.
149.Fn SSL_set1_host
150has been available since
151.Ox 6.5 ,
152and
153.Fn SSL_get0_peername
154since
155.Ox 6.8 .