ObjFW
Loading...
Searching...
No Matches
OFTLSStream.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im>
3 *
4 * All rights reserved.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License version 3.0 only,
8 * as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
13 * version 3.0 for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * version 3.0 along with this program. If not, see
17 * <https://www.gnu.org/licenses/>.
18 */
19
20#import "OFStream.h"
21#import "OFRunLoop.h"
22
23OF_ASSUME_NONNULL_BEGIN
24
27@class OFTLSStream;
28
38
44@protocol OFTLSStreamDelegate <OFStreamDelegate>
54- (void)stream: (OFTLSStream *)stream
55 didPerformClientHandshakeWithHost: (OFString *)host
56 exception: (nullable id)exception;
57@end
58
77{
78 OFStream <OFReadyForReadingObserving, OFReadyForWritingObserving>
79 *_underlyingStream;
80 bool _verifiesCertificates;
81 OF_RESERVE_IVARS(OFTLSStream, 4)
82}
83
87@property (readonly, nonatomic) OFStream <OFReadyForReadingObserving,
88 OFReadyForWritingObserving> *underlyingStream;
96@property OF_NULLABLE_PROPERTY (assign, nonatomic)
97 id <OFTLSStreamDelegate> delegate;
102@property (nonatomic) bool verifiesCertificates;
104- (instancetype)init OF_UNAVAILABLE;
105
114+ (instancetype)streamWithStream: (OFStream <OFReadyForReadingObserving,
115 OFReadyForWritingObserving> *)stream;
116
128- (instancetype)initWithStream: (OFStream <OFReadyForReadingObserving,
129 OFReadyForWritingObserving> *)stream
130 OF_DESIGNATED_INITIALIZER;
131
140- (void)asyncPerformClientHandshakeWithHost: (OFString *)host;
141
151- (void)asyncPerformClientHandshakeWithHost: (OFString *)host
152 runLoopMode: (OFRunLoopMode)runLoopMode;
153
161- (void)performClientHandshakeWithHost: (OFString *)host;
162@end
163
164#ifdef __cplusplus
165extern "C" {
166#endif
174extern Class OFTLSStreamImplementation;
175
183 OFTLSStreamErrorCode errorCode);
184#ifdef __cplusplus
185}
186#endif
187
188OF_ASSUME_NONNULL_END
OFTLSStreamErrorCode
An enum representing an error of an OFTLSStream.
Definition OFTLSStream.h:32
@ OFTLSStreamErrorCodeInitializationFailed
Initialization of the TLS context failed.
Definition OFTLSStream.h:36
@ OFTLSStreamErrorCodeUnknown
An unknown error.
Definition OFTLSStream.h:34
OFString * OFTLSStreamErrorCodeDescription(OFTLSStreamErrorCode errorCode)
Returns a string description for the TLS stream error code.
Definition OFTLSStream.m:52
Class OFTLSStreamImplementation
The implementation for OFTLSStream to use.
Definition OFTLSStream.m:37
A class for storing constant strings using the @"" literal.
Definition OFConstantString.h:42
A base class for different types of streams.
Definition OFStream.h:280
A class for handling strings.
Definition OFString.h:143
A class that provides Transport Layer Security on top of a stream.
Definition OFTLSStream.h:78
This protocol is implemented by classes which can be observed for readiness for reading by OFKernelEv...
Definition OFKernelEventObserver.h:83
This protocol is implemented by classes which can be observed for readiness for writing by OFKernelEv...
Definition OFKernelEventObserver.h:97