Differences From Artifact [d519c5a780]:
- File
src/OFTLSSocket.h
— part of check-in
[a5a3047210]
at
2021-11-05 22:42:16
on branch trunk
— Remove TLS server support
The current API is too tied to OpenSSL. (user: js, size: 1142) [annotate] [blame] [check-ins using]
To Artifact [38e4f875d1]:
- File
src/OFTLSSocket.h
— part of check-in
[34cb121dc5]
at
2021-11-06 00:10:48
on branch trunk
— Make OFTLSSocket an abstract class
This should make it easier to add TLS support using various
implementations. (user: js, size: 3479) [annotate] [blame] [check-ins using]
| ︙ | ︙ | |||
9 10 11 12 13 14 15 | * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ | | > > > > > > > > | | > > > > > > > > > > > > > > > > > | > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFTCPSocket.h"
OF_ASSUME_NONNULL_BEGIN
/**
* @protocol OFTLSSocketDelegate OFTLSSocket.h ObjFW/OFTLSSocket.h
*
* A delegate for OFTLSSocket.
*/
@protocol OFTLSSocketDelegate <OFTCPSocketDelegate>
@end
/**
* @class OFTLSSocket OFTLSSocket.h ObjFW/OFTLSSocket.h
*
* @brief A class that provides Transport Layer Security on top of a TCP socket.
*
* This class is a class cluster and returns a suitable OFTLSSocket subclass,
* if available.
*
* Subclasses need to override @ref accept, @ref lowlevelReadIntoBuffer:length:,
* @ref lowlevelWriteBuffer:length:, @ref lowlevelIsAtEndOfStream and
* @ref startTLSForHost:port:. In order to get access to the lowlevel TCP
* methods (you cannot call `super`, as the class is abstract), the private
* methods @ref TCPAccept, @ref lowlevelTCPReadIntoBuffer:length:,
* @ref lowlevelTCPWriteBuffer:length: and @ref lowlevelTCPIsAtEndOfStream are
* provided.
*/
@interface OFTLSSocket: OFTCPSocket
{
bool _verifiesCertificates;
OF_RESERVE_IVARS(OFTLSSocket, 4)
}
/**
* @brief The delegate for asynchronous operations on the socket.
*
* @note The delegate is retained for as long as asynchronous operations are
* still ongoing.
*/
@property OF_NULLABLE_PROPERTY (assign, nonatomic)
id <OFTLSSocketDelegate> delegate;
/**
* @brief Whether certificates are verified.
*
* The default is enabled.
*/
@property (nonatomic) bool verifiesCertificates;
/**
* @brief Initializes the TLS socket with the specified TCP socket as its
* underlying socket.
*
* @param socket The TCP socket to use as underlying socket
*/
- (instancetype)initWithSocket: (OFTCPSocket *)socket;
/**
* @brief Start TLS on the underlying socket with the assumption that it is
* connected to the specified host and port.
*
* @param host The host the socket is connected to, which is also used for
* verification
* @param port The port the socket is connected to
*/
- (void)startTLSForHost: (OFString *)host port: (uint16_t)port;
/**
* @brief This method should never be called directly. Only subclasses of
* @ref OFTLSSocket are allowed to call it.
*/
- (instancetype)TCPAccept;
/**
* @brief This method should never be called directly. Only subclasses of
* @ref OFTLSSocket are allowed to call it.
*/
- (size_t)lowlevelTCPReadIntoBuffer: (void *)buffer length: (size_t)length;
/**
* @brief This method should never be called directly. Only subclasses of
* @ref OFTLSSocket are allowed to call it.
*/
- (size_t)lowlevelTCPWriteBuffer: (const void *)buffer length: (size_t)length;
/**
* @brief This method should never be called directly. Only subclasses of
* @ref OFTLSSocket are allowed to call it.
*/
- (bool)lowlevelTCPIsAtEndOfStream;
@end
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief The concrete subclass of OFTLSSocket that should be used.
*/
extern Class _Nullable OFTLSSocketImplementation;
#ifdef __cplusplus
}
#endif
OF_ASSUME_NONNULL_END
|