Overview
Comment: | Adjust to ObjFW changes |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
895707613945b04727bffe6192aa5b49 |
User & Date: | js on 2021-11-06 00:15:34 |
Other Links: | manifest | tags |
Context
2021-11-07
| ||
20:04 | Adjust to ObjFW changes Leaf check-in: 22d082c6ea user: js tags: trunk | |
2021-11-06
| ||
00:15 | Adjust to ObjFW changes check-in: 8957076139 user: js tags: trunk | |
2021-04-25
| ||
20:41 | Adjust to ObjFW changes check-in: a64206ee2e user: js tags: trunk | |
Changes
Modified src/SSLSocket.h from [c4807a7400] to [0371d9e9ba].
︙ | ︙ | |||
33 34 35 36 37 38 39 | #import <ObjFW/OFTCPSocket.h> #import <ObjFW/OFTLSSocket.h> OF_ASSUME_NONNULL_BEGIN @class X509Certificate; | | | > > < | 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 | #import <ObjFW/OFTCPSocket.h> #import <ObjFW/OFTLSSocket.h> OF_ASSUME_NONNULL_BEGIN @class X509Certificate; @interface SSLSocket: OFTLSSocket { SSL *_SSL; OFString *_certificateFile, *_privateKeyFile; const char *_privateKeyPassphrase; bool _requestsClientCertificates; } @property (copy, nonatomic) OFString *certificateFile, *privateKeyFile; @property (nonatomic) const char *privateKeyPassphrase; @property (nonatomic) bool requestsClientCertificates; @property OF_NULLABLE_PROPERTY (readonly, nonatomic) X509Certificate *peerCertificate; - (OFData *)channelBindingDataWithType: (OFString *)type; - (nullable X509Certificate *)peerCertificate; - (void)verifyPeerCertificate; @end OF_ASSUME_NONNULL_END |
Modified src/SSLSocket.m from [6562bd487a] to [7c2c09a5dc].
︙ | ︙ | |||
73 74 75 76 77 78 79 | if (mode & CRYPTO_LOCK) OFEnsure(OFPlainMutexLock(&SSLMutexes[n]) == 0); else OFEnsure(OFPlainMutexUnlock(&SSLMutexes[n]) == 0); } @interface SSLSocket () | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | 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 | if (mode & CRYPTO_LOCK) OFEnsure(OFPlainMutexLock(&SSLMutexes[n]) == 0); else OFEnsure(OFPlainMutexUnlock(&SSLMutexes[n]) == 0); } @interface SSLSocket () - (void)SSL_super_close; @end @implementation SSLSocket @dynamic delegate; @synthesize certificateFile = _certificateFile; @synthesize privateKeyFile = _privateKeyFile; @synthesize privateKeyPassphrase = _privateKeyPassphrase; @synthesize requestsClientCertificates = _requestsClientCertificates; + (void)load { OFTLSSocketImplementation = self; } + (void)initialize { int m; if (self != [SSLSocket class]) |
︙ | ︙ | |||
198 199 200 201 202 203 204 | #endif if (SSL_CTX_set_default_verify_paths(ctx) == 0) @throw [OFInitializationFailedException exceptionWithClass: self]; } | < < < < < < < < < < < < < < < < < < < < < < < < | | 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | #endif if (SSL_CTX_set_default_verify_paths(ctx) == 0) @throw [OFInitializationFailedException exceptionWithClass: self]; } - (void)dealloc { SSL *SSL_ = _SSL; [_privateKeyFile release]; [_certificateFile release]; [super dealloc]; if (SSL_ != NULL) SSL_free(SSL_); } - (void)startTLSForHost: (OFString *)host port: (uint16_t)port { OFStringEncoding encoding; if ((_SSL = SSL_new(ctx)) == NULL || SSL_set_fd(_SSL, _socket) != 1) { unsigned long error = ERR_get_error(); [super close]; |
︙ | ︙ | |||
325 326 327 328 329 330 331 | exceptionWithHost: host port: port socket: self SSLError: error]; } } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 | exceptionWithHost: host port: port socket: self SSLError: error]; } } - (instancetype)accept { SSLSocket *client = [self TCPAccept]; OFStringEncoding encoding; if ((client->_SSL = SSL_new(ctx)) == NULL || !SSL_set_fd(client->_SSL, client->_socket)) { [client SSL_super_close]; /* FIXME: Get a proper errno */ @throw [OFAcceptFailedException exceptionWithSocket: self |
︙ | ︙ | |||
429 430 431 432 433 434 435 | /* * There is no SSL session yet. However, it might be necessary to read * from and write to the socket before negotiating an SSL session: For * example, the socket might be connected to a SOCKS5 proxy and needs * to establish a SOCKS5 connection before negotiating an SSL session. */ if (_SSL == NULL) | | | 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 | /* * There is no SSL session yet. However, it might be necessary to read * from and write to the socket before negotiating an SSL session: For * example, the socket might be connected to a SOCKS5 proxy and needs * to establish a SOCKS5 connection before negotiating an SSL session. */ if (_SSL == NULL) return [self lowlevelTCPReadIntoBuffer: buffer length: length]; if (length > INT_MAX) @throw [OFOutOfRangeException exception]; if (_socket == INVALID_SOCKET) @throw [OFNotOpenException exceptionWithObject: self]; |
︙ | ︙ | |||
472 473 474 475 476 477 478 | * to establish a SOCKS5 connection before negotiating an SSL session. * * TODO: Think of a way to make this safer, so that it's impossible to * forget to establish an SSL session and then send unencrypted data by * accident. */ if (_SSL == NULL) | | | | < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 | * to establish a SOCKS5 connection before negotiating an SSL session. * * TODO: Think of a way to make this safer, so that it's impossible to * forget to establish an SSL session and then send unencrypted data by * accident. */ if (_SSL == NULL) return [self lowlevelTCPWriteBuffer: buffer length: length]; if (_socket == INVALID_SOCKET) @throw [OFNotOpenException exceptionWithObject: self]; if (length > INT_MAX) @throw [OFOutOfRangeException exception]; if ((bytesWritten = SSL_write(_SSL, buffer, (int)length)) < 0) @throw [OFWriteFailedException exceptionWithObject: self requestedLength: length bytesWritten: 0 errNo: 0]; return bytesWritten; } - (bool)lowlevelIsAtEndOfStream { if (_SSL != NULL && SSL_pending(_SSL) > 0) return false; return [self lowlevelTCPIsAtEndOfStream]; } - (OFData *)channelBindingDataWithType: (OFString *)type { size_t length; char buffer[64]; |
︙ | ︙ |