From db1795aa38697d032e96b39539bd30f84d4f060e Mon Sep 17 00:00:00 2001 From: Leo Vandriel Date: Wed, 14 Jan 2015 15:10:48 -0800 Subject: [PATCH] add additional ssl handshake error codes --- CHANGLOG.md | 2 ++ Classes/NWSSLConnection.m | 6 ++++++ Classes/NWType.h | 12 ++++++++++++ Classes/NWType.m | 6 ++++++ 4 files changed, 26 insertions(+) diff --git a/CHANGLOG.md b/CHANGLOG.md index 07c764a..7ee03aa 100644 --- a/CHANGLOG.md +++ b/CHANGLOG.md @@ -3,6 +3,8 @@ Change Log ### master (unreleased) +* Add SSL handshake error codes + ### 0.6.0 (2014-10-30) * Remove kNWSuccess diff --git a/Classes/NWSSLConnection.m b/Classes/NWSSLConnection.m index 0e18fe8..91379f5 100644 --- a/Classes/NWSSLConnection.m +++ b/Classes/NWSSLConnection.m @@ -134,6 +134,12 @@ - (BOOL)handshakeSSLWithError:(NSError *__autoreleasing *)error case errSSLWouldBlock: return [NWErrorUtil noWithErrorCode:kNWErrorSSLHandshakeTimeout error:error]; case errSecIO: return [NWErrorUtil noWithErrorCode:kNWErrorSSLDroppedByServer error:error]; case errSecAuthFailed: return [NWErrorUtil noWithErrorCode:kNWErrorSSLAuthFailed error:error]; + case errSSLUnknownRootCert: return [NWErrorUtil noWithErrorCode:kNWErrorSSLHandshakeUnknownRootCert error:error]; + case errSSLNoRootCert: return [NWErrorUtil noWithErrorCode:kNWErrorSSLHandshakeNoRootCert error:error]; + case errSSLCertExpired: return [NWErrorUtil noWithErrorCode:kNWErrorSSLHandshakeCertExpired error:error]; + case errSSLXCertChainInvalid: return [NWErrorUtil noWithErrorCode:kNWErrorSSLHandshakeXCertChainInvalid error:error]; + case errSSLClientCertRequested: return [NWErrorUtil noWithErrorCode:kNWErrorSSLHandshakeClientCertRequested error:error]; + case errSSLServerAuthCompleted: return [NWErrorUtil noWithErrorCode:kNWErrorSSLHandshakeServerAuthCompleted error:error]; } return [NWErrorUtil noWithErrorCode:kNWErrorSSLHandshakeFail error:error]; } diff --git a/Classes/NWType.h b/Classes/NWType.h index 788feaa..2baffba 100644 --- a/Classes/NWType.h +++ b/Classes/NWType.h @@ -93,6 +93,18 @@ typedef NS_ENUM(NSInteger, NWError) { kNWErrorSSLAuthFailed = -208, /** SSL handshake failed. */ kNWErrorSSLHandshakeFail = -209, + /** SSL handshake root not a known anchor. */ + kNWErrorSSLHandshakeUnknownRootCert = -223, + /** SSL handshake chain not verifiable to root. */ + kNWErrorSSLHandshakeNoRootCert = -224, + /** SSL handshake chain has expired certificates. */ + kNWErrorSSLHandshakeCertExpired = -225, + /** SSL handshake invalid certificate chain. */ + kNWErrorSSLHandshakeXCertChainInvalid = -226, + /** SSL handshake expecting client cert. */ + kNWErrorSSLHandshakeClientCertRequested = -227, + /** SSL handshake auth interrupted. */ + kNWErrorSSLHandshakeServerAuthCompleted = -228, /** SSL handshake timeout. */ kNWErrorSSLHandshakeTimeout = -218, diff --git a/Classes/NWType.m b/Classes/NWType.m index 5a32282..749721b 100644 --- a/Classes/NWType.m +++ b/Classes/NWType.m @@ -47,6 +47,12 @@ + (NSString *)stringWithCode:(NWError)code case kNWErrorSSLDroppedByServer : return @"SSL handshake dropped by server"; case kNWErrorSSLAuthFailed : return @"SSL handshake authentication failed"; case kNWErrorSSLHandshakeFail : return @"SSL handshake failed"; + case kNWErrorSSLHandshakeUnknownRootCert : return @"SSL handshake root not a known anchor"; + case kNWErrorSSLHandshakeNoRootCert : return @"SSL handshake chain not verifiable to root"; + case kNWErrorSSLHandshakeCertExpired : return @"SSL handshake chain has expired certificates"; + case kNWErrorSSLHandshakeXCertChainInvalid : return @"SSL handshake invalid certificate chain"; + case kNWErrorSSLHandshakeClientCertRequested : return @"SSL handshake expecting client cert"; + case kNWErrorSSLHandshakeServerAuthCompleted : return @"SSL handshake auth interrupted"; case kNWErrorSSLHandshakeTimeout : return @"SSL handshake timeout"; case kNWErrorReadDroppedByServer : return @"Read connection dropped by server";