Differences From Artifact [72b1fab442]:
- File src/SSLSocket.m — part of check-in [09e348c39a] at 2013-03-04 17:37:09 on branch trunk — Replace BOOL with bool. (user: js, size: 10381) [annotate] [blame] [check-ins using]
To Artifact [20965632b7]:
- File
src/SSLSocket.m
— part of check-in
[4192ab66c8]
at
2013-03-31 10:04:53
on branch trunk
— Conform to OFTLSSocket.
Still a few FIXMEs / TODOs. (user: js, size: 9773) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
111 112 113 114 115 116 117 | if (SSL_CTX_set_default_verify_paths(ctx) == 0) @throw [OFInitializationFailedException exceptionWithClass: self]; } - initWithSocket: (OFTCPSocket*)socket { | < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < | | > > > > > > > > > > > > > > > > > | | 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 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 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | if (SSL_CTX_set_default_verify_paths(ctx) == 0) @throw [OFInitializationFailedException exceptionWithClass: self]; } - initWithSocket: (OFTCPSocket*)socket { self = [self init]; _socket = dup(socket->_socket); return self; } - (void)dealloc { SSL *SSL_ = _SSL; [_privateKeyFile release]; [_certificateFile release]; [super dealloc]; if (SSL_ != NULL) SSL_free(SSL_); } - (void)startTLS { if ((_SSL = SSL_new(ctx)) == NULL || !SSL_set_fd(_SSL, _socket)) { [super close]; @throw [OFConnectionFailedException exceptionWithClass: [self class] socket: self host: nil port: 0]; } SSL_set_connect_state(_SSL); if ((_privateKeyFile != nil && !SSL_use_PrivateKey_file(_SSL, [_privateKeyFile cStringWithEncoding: OF_STRING_ENCODING_NATIVE], SSL_FILETYPE_PEM)) || (_certificateFile != nil && !SSL_use_certificate_file(_SSL, [_certificateFile cStringWithEncoding: OF_STRING_ENCODING_NATIVE], SSL_FILETYPE_PEM)) || SSL_connect(_SSL) != 1) { [super close]; @throw [OFConnectionFailedException exceptionWithClass: [self class] socket: self host: nil port: 0]; } } - (void)connectToHost: (OFString*)host port: (uint16_t)port { [super connectToHost: host port: port]; @try { [self startTLS]; } @catch (OFConnectionFailedException *e) { @throw [OFConnectionFailedException exceptionWithClass: [self class] socket: self host: host port: port]; } } - (instancetype)accept { SSLSocket *client = (SSLSocket*)[super accept]; if ((client->_SSL = SSL_new(ctx)) == NULL || !SSL_set_fd(client->_SSL, client->_socket)) { [client SSL_super_close]; @throw [OFAcceptFailedException exceptionWithClass: [self class] |
︙ | ︙ | |||
329 330 331 332 333 334 335 | { if (_SSL == NULL) return [super numberOfBytesInReadBuffer]; return [super numberOfBytesInReadBuffer] + SSL_pending(_SSL); } | | | > > | > | > > > > > > > > > > > > > > > > > > > > > | 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 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 | { if (_SSL == NULL) return [super numberOfBytesInReadBuffer]; return [super numberOfBytesInReadBuffer] + SSL_pending(_SSL); } - (void)setDelegate: (id <OFTLSSocketDelegate>)delegate { /* FIXME */ [self doesNotRecognizeSelector: _cmd]; abort(); } - (id <OFTLSSocketDelegate>)delegate { /* FIXME */ return nil; } - (void)setCertificateFile: (OFString*)certificateFile { OF_SETTER(_certificateFile, certificateFile, true, 1) } - (OFString*)certificateFile { OF_GETTER(_certificateFile, true) } - (void)setPrivateKeyFile: (OFString*)privateKeyFile { OF_SETTER(_privateKeyFile, privateKeyFile, true, 1) } - (OFString*)privateKeyFile { OF_GETTER(_privateKeyFile, true) } - (void)setPrivateKeyPassphrase: (const char*)privateKeyPassphrase { /* FIXME */ } - (const char*)privateKeyPassphrase { /* FIXME */ return NULL; } - (void)setRequestsClientCertificates: (bool)enabled { _requestsClientCertificates = enabled; } - (bool)requestsClientCertificates |
︙ | ︙ |