ObjFW
OFTLSSocket.h
1 /*
2  * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015
3  * Jonathan Schleifer <js@webkeks.org>
4  *
5  * All rights reserved.
6  *
7  * This file is part of ObjFW. It may be distributed under the terms of the
8  * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
9  * the packaging of this file.
10  *
11  * Alternatively, it may be distributed under the terms of the GNU General
12  * Public License, either version 2 or 3, which can be found in the file
13  * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
14  * file.
15  */
16 
17 #import "OFObject.h"
18 
19 OF_ASSUME_NONNULL_BEGIN
20 
21 @class OFString;
22 @class OFDictionary OF_GENERIC(KeyType, ObjectType);
23 @protocol OFTLSSocket;
24 
31 #ifdef OF_HAVE_OPTIONAL_PROTOCOLS
32 @optional
33 #endif
34 
48 - (bool)socket: (id <OFTLSSocket>)socket
49  shouldAcceptCertificate: (OFDictionary*)certificate;
50 @end
51 
58 @protocol OFTLSSocket
59 #ifdef OF_HAVE_PROPERTIES
60 @property OF_NULLABLE_PROPERTY (assign) id <OFTLSSocketDelegate> delegate;
61 @property OF_NULLABLE_PROPERTY (copy)
63 @property OF_NULLABLE_PROPERTY (assign) const char *privateKeyPassphrase;
64 @property (getter=isCertificateVerificationEnabled)
65  bool certificateVerificationEnabled;
66 #endif
67 
74 - initWithSocket: (OFTCPSocket*)socket;
75 
85 - (void)startTLSWithExpectedHost: (OFString*)host;
86 
92 - (void)setDelegate: (nullable id <OFTLSSocketDelegate>)delegate;
93 
99 - (nullable id <OFTLSSocketDelegate>)delegate;
100 
106 - (void)setCertificateFile: (nullable OFString*)certificateFile;
107 
117 - (void)setCertificateFile: (OFString*)certificateFile
118  forSNIHost: (OFString*)SNIHost;
119 
125 - (nullable OFString*)certificateFile;
126 
137 - (nullable OFString*)certificateFileForSNIHost: (OFString*)SNIHost;
138 
144 - (void)setPrivateKeyFile: (nullable OFString*)privateKeyFile;
145 
154 - (void)setPrivateKeyFile: (OFString*)privateKeyFile
155  forSNIHost: (OFString*)SNIHost;
156 
163 - (nullable OFString*)privateKeyFile;
164 
175 - (nullable OFString*)privateKeyFileForSNIHost: (OFString*)SNIHost;
176 
186 - (void)setPrivateKeyPassphrase: (nullable const char*)privateKeyPassphrase;
187 
200 - (void)setPrivateKeyPassphrase: (const char*)privateKeyPassphrase
201  forSNIHost: (OFString*)SNIHost;
202 
210 - (nullable const char*)privateKeyPassphrase;
211 
224 - (nullable const char*)privateKeyPassphraseForSNIHost: (OFString*)SNIHost;
225 
233 - (void)setCertificateVerificationEnabled: (bool)enabled;
234 
241 @end
242 
243 OF_ASSUME_NONNULL_END
nullable id< OFTLSSocketDelegate > delegate()
Returns the delegate used by the TLS socket.
A protocol that should be implemented by 3rd-party libraries implementing TLS.
Definition: OFTLSSocket.h:58
bool isCertificateVerificationEnabled()
Returns whether certificate verification is enabled.
A class for handling strings.
Definition: OFString.h:91
nullable OFString * privateKeyFile()
Returns the path of the PKCS#8 private key file used by the TLS socket.
An abstract class for storing objects in a dictionary.
Definition: OFDictionary.h:61
A class which provides functions to create and use TCP sockets.
Definition: OFTCPSocket.h:61
nullable const char * privateKeyPassphrase()
Returns the passphrase to decrypt the PKCS#8 private key file.
A delegate for classes implementing the OFTLSSocket protocol.
Definition: OFTLSSocket.h:30
nullable OFString * certificateFile()
Returns the path of the X.509 certificate file used by the TLS socket.