Index: configure.ac ================================================================== --- configure.ac +++ configure.ac @@ -48,11 +48,11 @@ AS_IF([test x"$GOBJC" = x"yes"], [ OBJCFLAGS="$OBJCFLAGS -Wwrite-strings -Wpointer-arith" dnl We need -Wno-deprecated-declarations as OpenSSL is deprecated on dnl OS X. - OBJCFLAGS="$OBJCFLAGS -Wno-deprecated-declarations" # -Werror + OBJCFLAGS="$OBJCFLAGS -Wno-deprecated-declarations" ]) BUILDSYS_INIT BUILDSYS_TOUCH_DEPS Index: src/SSLInvalidCertificateException.h ================================================================== --- src/SSLInvalidCertificateException.h +++ src/SSLInvalidCertificateException.h @@ -31,11 +31,9 @@ #ifdef OF_HAVE_PROPERTIES @property (readonly, assign) OFString *reason; #endif -+ exceptionWithClass: (Class)class - reason: (OFString*)reason; -- initWithClass: (Class)class - reason: (OFString*)reason; ++ exceptionWithReason: (OFString*)reason; +- initWithReason: (OFString*)reason; - (OFString*)reason; @end Index: src/SSLInvalidCertificateException.m ================================================================== --- src/SSLInvalidCertificateException.m +++ src/SSLInvalidCertificateException.m @@ -26,18 +26,16 @@ #import "SSLInvalidCertificateException.h" #import @implementation SSLInvalidCertificateException -+ exceptionWithClass: (Class)class - reason: (OFString*)reason -{ - return [[[self alloc] initWithClass: class - reason: reason] autorelease]; -} - -- initWithClass: (Class)class ++ exceptionWithReason: (OFString*)reason +{ + return [[[self alloc] initWithReason: reason] autorelease]; +} + +- init { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @@ -45,14 +43,13 @@ } abort(); } -- initWithClass: (Class)class - reason: (OFString*)reason +- initWithReason: (OFString*)reason { - self = [super initWithClass: class]; + self = [super init]; @try { _reason = [reason copy]; } @catch (id e) { [self release]; @@ -70,14 +67,13 @@ } - (OFString*)description { return [OFString stringWithFormat: - @"Invalid certificate in class %@! Reason: %@", [self inClass], - _reason]; + @"Invalid certificate! Reason: %@", _reason]; } - (OFString*)reason { OF_GETTER(_reason, false) } @end Index: src/SSLSocket.m ================================================================== --- src/SSLSocket.m +++ src/SSLSocket.m @@ -138,14 +138,13 @@ - (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]; + exceptionWithHost: nil + port: 0 + socket: self]; } SSL_set_connect_state(_SSL); if ((_privateKeyFile != nil && !SSL_use_PrivateKey_file(_SSL, @@ -154,43 +153,33 @@ !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]; + exceptionWithHost: nil + port: 0 + socket: self]; } } - (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]; - } + [self startTLS]; } - (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] - socket: self]; + @throw [OFAcceptFailedException exceptionWithSocket: self]; } if (_requestsClientCertificates) SSL_set_verify(client->_SSL, SSL_VERIFY_PEER, NULL); @@ -200,12 +189,11 @@ cStringWithEncoding: OF_STRING_ENCODING_NATIVE], SSL_FILETYPE_PEM) || !SSL_use_certificate_file(client->_SSL, [_certificateFile cStringWithEncoding: OF_STRING_ENCODING_NATIVE], SSL_FILETYPE_PEM) || SSL_accept(client->_SSL) != 1) { [client SSL_super_close]; - @throw [OFAcceptFailedException exceptionWithClass: [self class] - socket: self]; + @throw [OFAcceptFailedException exceptionWithSocket: self]; } return client; } @@ -226,22 +214,20 @@ length: (size_t)length { ssize_t ret; if (length > INT_MAX) - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; if (_socket == INVALID_SOCKET) - @throw [OFNotConnectedException exceptionWithClass: [self class] - socket: self]; + @throw [OFNotConnectedException exceptionWithSocket: self]; if (_atEndOfStream) { OFReadFailedException *e; - e = [OFReadFailedException exceptionWithClass: [self class] - stream: self - requestedLength: length]; + e = [OFReadFailedException exceptionWithStream: self + requestedLength: length]; #ifndef _WIN32 e->_errNo = ENOTCONN; #else e->_errNo = WSAENOTCONN; #endif @@ -251,13 +237,12 @@ if ((ret = SSL_read(_SSL, buffer, (int)length)) < 0) { if (SSL_get_error(_SSL, ret) == SSL_ERROR_WANT_READ) return 0; - @throw [OFReadFailedException exceptionWithClass: [self class] - stream: self - requestedLength: length]; + @throw [OFReadFailedException exceptionWithStream: self + requestedLength: length]; } if (ret == 0) _atEndOfStream = true; @@ -266,22 +251,20 @@ - (void)lowlevelWriteBuffer: (const void*)buffer length: (size_t)length { if (length > INT_MAX) - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; if (_socket == INVALID_SOCKET) - @throw [OFNotConnectedException exceptionWithClass: [self class] - socket: self]; + @throw [OFNotConnectedException exceptionWithSocket: self]; if (_atEndOfStream) { OFWriteFailedException *e; - e = [OFWriteFailedException exceptionWithClass: [self class] - stream: self - requestedLength: length]; + e = [OFWriteFailedException exceptionWithStream: self + requestedLength: length]; #ifndef _WIN32 e->_errNo = ENOTCONN; #else e->_errNo = WSAENOTCONN; @@ -289,13 +272,12 @@ @throw e; } if (SSL_write(_SSL, buffer, (int)length) < length) - @throw [OFWriteFailedException exceptionWithClass: [self class] - stream: self - requestedLength: length]; + @throw [OFWriteFailedException exceptionWithStream: self + requestedLength: length]; } - (size_t)numberOfBytesInReadBuffer { if (_SSL == NULL) @@ -363,13 +345,11 @@ size_t length; char buffer[64]; OFDataArray *data; if (![type isEqual: @"tls-unique"]) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; if (SSL_session_reused(_SSL) ^ !_listening) { /* * We are either client or the session has been resumed * => we have sent the finished message @@ -405,14 +385,12 @@ if (SSL_get_peer_certificate(_SSL) != NULL) { if ((ret = SSL_get_verify_result(_SSL)) != X509_V_OK) { const char *tmp = X509_verify_cert_error_string(ret); OFString *reason = [OFString stringWithUTF8String: tmp]; @throw [SSLInvalidCertificateException - exceptionWithClass: [self class] - reason: reason]; + exceptionWithReason: reason]; } } else @throw [SSLInvalidCertificateException - exceptionWithClass: [self class] - reason: @"No certificate"]; + exceptionWithReason: @"No certificate"]; } @end Index: src/X509Certificate.m ================================================================== --- src/X509Certificate.m +++ src/X509Certificate.m @@ -51,11 +51,11 @@ const unsigned char *dataCArray = [data items]; _certificate = d2i_X509(NULL, &dataCArray, [data count]); if (_certificate == NULL) @throw [OFInitializationFailedException - exceptionWithClass: [self class]]; + exceptionWithClass: [self class]]; [pool release]; } @catch (id e) { [self release]; @throw e; @@ -70,11 +70,11 @@ @try { _certificate = X509_dup(certificate); if (_certificate == NULL) @throw [OFInitializationFailedException - exceptionWithClass: [self class]]; + exceptionWithClass: [self class]]; } @catch (id e) { [self release]; @throw e; } @@ -419,12 +419,11 @@ { OFString *ret; char *buffer; if (ASN1_STRING_to_UTF8((unsigned char**)&buffer, str) < 0) - @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + @throw [OFInvalidEncodingException exception]; @try { ret = [OFString stringWithUTF8String: buffer]; } @finally { OPENSSL_free(buffer);