1.\" $OpenBSD: SSL_set_connect_state.3,v 1.6 2018/03/27 17:35:50 schwarze Exp $ 2.\" full merge up to OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 3.\" selective merge up to: OpenSSL dbd007d7 Jul 28 13:31:27 2017 +0800 4.\" 5.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org> 6.\" and Paul Yang <yang.yang@baishancloud.com>. 7.\" Copyright (c) 2001, 2017 The OpenSSL Project. All rights reserved. 8.\" 9.\" Redistribution and use in source and binary forms, with or without 10.\" modification, are permitted provided that the following conditions 11.\" are met: 12.\" 13.\" 1. Redistributions of source code must retain the above copyright 14.\" notice, this list of conditions and the following disclaimer. 15.\" 16.\" 2. Redistributions in binary form must reproduce the above copyright 17.\" notice, this list of conditions and the following disclaimer in 18.\" the documentation and/or other materials provided with the 19.\" distribution. 20.\" 21.\" 3. All advertising materials mentioning features or use of this 22.\" software must display the following acknowledgment: 23.\" "This product includes software developed by the OpenSSL Project 24.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)" 25.\" 26.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 27.\" endorse or promote products derived from this software without 28.\" prior written permission. For written permission, please contact 29.\" openssl-core@openssl.org. 30.\" 31.\" 5. Products derived from this software may not be called "OpenSSL" 32.\" nor may "OpenSSL" appear in their names without prior written 33.\" permission of the OpenSSL Project. 34.\" 35.\" 6. Redistributions of any form whatsoever must retain the following 36.\" acknowledgment: 37.\" "This product includes software developed by the OpenSSL Project 38.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)" 39.\" 40.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 41.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 42.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 43.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 44.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 45.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 46.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 47.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 48.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 49.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 51.\" OF THE POSSIBILITY OF SUCH DAMAGE. 52.\" 53.Dd $Mdocdate: March 27 2018 $ 54.Dt SSL_SET_CONNECT_STATE 3 55.Os 56.Sh NAME 57.Nm SSL_set_connect_state , 58.Nm SSL_set_accept_state , 59.Nm SSL_is_server 60.Nd prepare SSL object to work in client or server mode 61.Sh SYNOPSIS 62.In openssl/ssl.h 63.Ft void 64.Fn SSL_set_connect_state "SSL *ssl" 65.Ft void 66.Fn SSL_set_accept_state "SSL *ssl" 67.Ft int 68.Fn SSL_is_server "const SSL *ssl" 69.Sh DESCRIPTION 70.Fn SSL_set_connect_state 71sets 72.Fa ssl 73to work in client mode. 74.Pp 75.Fn SSL_set_accept_state 76sets 77.Fa ssl 78to work in server mode. 79.Pp 80.Fn SSL_is_server 81checks whether 82.Fa ssl 83is set to server mode. 84.Pp 85When the 86.Vt SSL_CTX 87object was created with 88.Xr SSL_CTX_new 3 , 89it was either assigned a dedicated client method, a dedicated server method, or 90a generic method, that can be used for both client and server connections. 91(The method might have been changed with 92.Xr SSL_CTX_set_ssl_version 3 93or 94.Xr SSL_set_ssl_method 3 . ) 95.Pp 96When beginning a new handshake, the SSL engine must know whether it must call 97the connect (client) or accept (server) routines. 98Even though it may be clear from the method chosen whether client or server 99mode was requested, the handshake routines must be explicitly set. 100.Pp 101When using the 102.Xr SSL_connect 3 103or 104.Xr SSL_accept 3 105routines, the correct handshake routines are automatically set. 106When performing a transparent negotiation using 107.Xr SSL_write 3 108or 109.Xr SSL_read 3 , 110the handshake routines must be explicitly set in advance using either 111.Fn SSL_set_connect_state 112or 113.Fn SSL_set_accept_state . 114.Pp 115If 116.Fn SSL_is_server 117is called before 118.Fn SSL_set_connect_state 119or 120.Fn SSL_set_accept_state 121was called either automatically or explicitly, 122the result depends on what method was used when the 123.Fa SSL_CTX 124was created. 125If a generic method or a dedicated server method was passed to 126.Xr SSL_CTX_new 3 , 127.Fn SSL_is_server 128returns 1; otherwise, it returns 0. 129.Sh RETURN VALUES 130.Fn SSL_is_server 131returns 1 if 132.Fa ssl 133is set to server mode or 0 if it is set to client mode. 134.Sh SEE ALSO 135.Xr ssl 3 , 136.Xr SSL_accept 3 , 137.Xr SSL_connect 3 , 138.Xr SSL_CTX_new 3 , 139.Xr SSL_CTX_set_ssl_version 3 , 140.Xr SSL_do_handshake 3 , 141.Xr SSL_new 3 , 142.Xr SSL_read 3 , 143.Xr SSL_write 3 144.Sh HISTORY 145.Fn SSL_set_connect_state 146and 147.Fn SSL_set_accept_state 148first appeared in SSLeay 0.6.0 and have been available since 149.Ox 2.4 . 150.Pp 151.Fn SSL_is_server 152first appeared in OpenSSL 1.0.2 and has been available since 153.Ox 6.3 . 154