@@ -57,14 +57,16 @@ return; SSL_library_init(); if ((ctx = SSL_CTX_new(SSLv23_method())) == NULL) - @throw [OFInitializationFailedException newWithClass: self]; + @throw [OFInitializationFailedException + exceptionWithClass: self]; if ((SSL_CTX_set_options(ctx, SSL_OP_NO_SSLv2) & SSL_OP_NO_SSLv2) == 0) - @throw [OFInitializationFailedException newWithClass: self]; + @throw [OFInitializationFailedException + exceptionWithClass: self]; } - initWithSocket: (OFTCPSocket*)socket { self = [self init]; @@ -74,11 +76,11 @@ if ((ssl = SSL_new(ctx)) == NULL || !SSL_set_fd(ssl, sock)) { close(sock); sock = INVALID_SOCKET; @throw [OFInitializationFailedException - newWithClass: isa]; + exceptionWithClass: isa]; } SSL_set_connect_state(ssl); if ((privateKeyFile != nil && !SSL_use_PrivateKey_file(ssl, @@ -89,11 +91,11 @@ OF_STRING_ENCODING_NATIVE], SSL_FILETYPE_PEM)) || SSL_connect(ssl) != 1) { close(sock); sock = INVALID_SOCKET; @throw [OFInitializationFailedException - newWithClass: isa]; + exceptionWithClass: isa]; } } @catch (id e) { [self release]; @throw e; } @@ -120,14 +122,14 @@ [super connectToHost: host port: port]; if ((ssl = SSL_new(ctx)) == NULL || !SSL_set_fd(ssl, sock)) { [super close]; - @throw [OFConnectionFailedException newWithClass: isa - socket: self - host: host - port: port]; + @throw [OFConnectionFailedException exceptionWithClass: isa + socket: self + host: host + port: port]; } SSL_set_connect_state(ssl); if ((privateKeyFile != nil && !SSL_use_PrivateKey_file(ssl, @@ -135,14 +137,14 @@ 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 newWithClass: isa - socket: self - host: host - port: port]; + @throw [OFConnectionFailedException exceptionWithClass: isa + socket: self + host: host + port: port]; } } - (SSLSocket*)accept { @@ -153,12 +155,12 @@ /* We only want to close the OFTCPSocket */ newSocket->isa = [OFTCPSocket class]; [newSocket close]; newSocket->isa = isa; - @throw [OFAcceptFailedException newWithClass: isa - socket: self]; + @throw [OFAcceptFailedException exceptionWithClass: isa + socket: self]; } SSL_set_accept_state(newSocket->ssl); if (!SSL_use_PrivateKey_file(newSocket->ssl, [privateKeyFile @@ -169,12 +171,12 @@ /* We only want to close the OFTCPSocket */ newSocket->isa = [OFTCPSocket class]; [newSocket close]; newSocket->isa = isa; - @throw [OFAcceptFailedException newWithClass: isa - socket: self]; + @throw [OFAcceptFailedException exceptionWithClass: isa + socket: self]; } return newSocket; } @@ -189,22 +191,22 @@ intoBuffer: (void*)buffer { ssize_t ret; if (length > INT_MAX) - @throw [OFOutOfRangeException newWithClass: isa]; + @throw [OFOutOfRangeException exceptionWithClass: isa]; if (sock == INVALID_SOCKET) - @throw [OFNotConnectedException newWithClass: isa - socket: self]; + @throw [OFNotConnectedException exceptionWithClass: isa + socket: self]; if (atEndOfStream) { OFReadFailedException *e; - e = [OFReadFailedException newWithClass: isa - stream: self - requestedLength: length]; + e = [OFReadFailedException exceptionWithClass: isa + stream: self + requestedLength: length]; #ifndef _WIN32 e->errNo = ENOTCONN; #else e->errNo = WSAENOTCONN; #endif @@ -211,13 +213,13 @@ @throw e; } if ((ret = SSL_read(ssl, buffer, (int)length)) < 0) - @throw [OFReadFailedException newWithClass: isa - stream: self - requestedLength: length]; + @throw [OFReadFailedException exceptionWithClass: isa + stream: self + requestedLength: length]; if (ret == 0) atEndOfStream = YES; return ret; @@ -225,21 +227,21 @@ - (void)_writeNBytes: (size_t)length fromBuffer: (const void*)buffer { if (length > INT_MAX) - @throw [OFOutOfRangeException newWithClass: isa]; + @throw [OFOutOfRangeException exceptionWithClass: isa]; if (sock == INVALID_SOCKET) - @throw [OFNotConnectedException newWithClass: isa - socket: self]; + @throw [OFNotConnectedException exceptionWithClass: isa + socket: self]; if (atEndOfStream) { OFWriteFailedException *e; - e = [OFWriteFailedException newWithClass: isa - stream: self + e = [OFWriteFailedException exceptionWithClass: isa + stream: self requestedLength: length]; #ifndef _WIN32 e->errNo = ENOTCONN; #else @@ -248,13 +250,13 @@ @throw e; } if (SSL_write(ssl, buffer, (int)length) < length) - @throw [OFWriteFailedException newWithClass: isa - stream: self - requestedLength: length]; + @throw [OFWriteFailedException exceptionWithClass: isa + stream: self + requestedLength: length]; } - (size_t)pendingBytes { return [super pendingBytes] + SSL_pending(ssl); @@ -285,12 +287,12 @@ int length; char buffer[64]; OFDataArray *data; if (![type isEqual: @"tls-unique"]) - @throw [OFInvalidArgumentException newWithClass: isa - selector: _cmd]; + @throw [OFInvalidArgumentException exceptionWithClass: isa + selector: _cmd]; if (SSL_session_reused(ssl) ^ !listening) { /* * We are either client or the session has been resumed * => we have sent the finished message