mirror of
https://github.com/Codeux-Software/Textual.git
synced 2026-06-16 13:24:32 +00:00
Modify -descriptionForErrorCode:
The method is now nonnull and returns "Unknown" for out of range error codes
This commit is contained in:
@@ -32,7 +32,8 @@ typedef NS_ENUM(NSUInteger, RCMCipherSuiteCollection) {
|
||||
|
||||
+ (BOOL)isTLSError:(NSError *)error;
|
||||
+ (nullable NSString *)descriptionForError:(NSError *)error;
|
||||
+ (nullable NSString *)descriptionForErrorCode:(NSInteger)errorCode;
|
||||
/* -descriptionForErrorCode: returns "Unknown" for out of range error codes */
|
||||
+ (NSString *)descriptionForErrorCode:(NSInteger)errorCode;
|
||||
+ (nullable NSString *)descriptionForBadCertificateError:(NSError *)error;
|
||||
+ (nullable NSString *)descriptionForBadCertificateErrorCode:(NSInteger)errorCode;
|
||||
+ (BOOL)isBadCertificateError:(NSError *)error;
|
||||
@@ -45,3 +46,4 @@ typedef NS_ENUM(NSUInteger, RCMCipherSuiteCollection) {
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
|
||||
@@ -58,6 +58,8 @@
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
static OSStatus errSSLUnknownError = -9999;
|
||||
|
||||
static const int kAEADMACValue = 7;
|
||||
|
||||
static const int kTLS13KeyExchangeValue = 31;
|
||||
@@ -561,10 +563,10 @@ static const char * _Nonnull kMacNames[] = {
|
||||
return [self descriptionForErrorCode:error.code];
|
||||
}
|
||||
|
||||
+ (nullable NSString *)descriptionForErrorCode:(NSInteger)errorCode
|
||||
+ (NSString *)descriptionForErrorCode:(NSInteger)errorCode
|
||||
{
|
||||
if (errorCode > (-9800) || errorCode < (-9865)) {
|
||||
return nil;
|
||||
errorCode = errSSLUnknownError;
|
||||
}
|
||||
|
||||
/* Request the heading for the formatted error message. */
|
||||
|
||||
@@ -208,19 +208,18 @@ extension ConnectionError
|
||||
self.init(tlsError: error.code)
|
||||
}
|
||||
|
||||
init? (tlsError errorCode: Int)
|
||||
/// init(tlsError:) returns .unableToSecure("Unknown") for out of range error codes
|
||||
init (tlsError errorCode: Int)
|
||||
{
|
||||
if let certError = RCMSecureTransport.description(forBadCertificateErrorCode: errorCode) {
|
||||
self = .badCertificate(failureReason: certError)
|
||||
|
||||
return
|
||||
} else if let tlsError = RCMSecureTransport.description(forErrorCode: errorCode) {
|
||||
self = .unableToSecure(failureReason: tlsError)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
return nil
|
||||
let tlsError = RCMSecureTransport.description(forErrorCode: errorCode)
|
||||
|
||||
self = .unableToSecure(failureReason: tlsError)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
@@ -103,3 +103,6 @@
|
||||
"-9863" = "Certificate required"; // errSSLCertificateRequired
|
||||
"-9864" = "Unknown PSK identity"; // errSSLUnknownPSKIdentity
|
||||
"-9865" = "Unknown or unrecognized name"; // errSSLUnrecognizedName
|
||||
|
||||
/* errSSLUnknownError is defined by our own library. Not Secure Transport. */
|
||||
"-9999" = "Unknown"; // errSSLUnknownError
|
||||
|
||||
Reference in New Issue
Block a user