Artifact 2e553f0270378ce75fff707a73bc66e134638b22c87950e466189a0c0bc864c9:
- File
src/exceptions/OFTLSHandshakeFailedException.m
— part of check-in
[112eb62f7b]
at
2021-11-13 20:28:25
on branch trunk
— Add OFSecureTransportTLSStream
This implements OFTLSStream using Apple's Secure Transport. While Secure
Transport is declared deprecated by Apple, Apple so far has failed to
provide a suitable replacement. They recommend Network.framework as a
replacement, however it can neither work on arbitrary sockets, nor can
it do STARTTLS. (user: js, size: 1860) [annotate] [blame] [check-ins using]
/* * Copyright (c) 2008-2021 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #import "OFTLSHandshakeFailedException.h" #import "OFString.h" @implementation OFTLSHandshakeFailedException @synthesize stream = _stream, host = _host, errorCode = _errorCode; + (instancetype)exception { OF_UNRECOGNIZED_SELECTOR } + (instancetype)exceptionWithStream: (OFTLSStream *)stream host: (OFString *)host errorCode: (OFTLSStreamErrorCode)errorCode { return [[[self alloc] initWithStream: stream host: host errorCode: errorCode] autorelease]; } - (instancetype)init { OF_INVALID_INIT_METHOD } - (instancetype)initWithStream: (OFTLSStream *)stream host: (OFString *)host errorCode: (OFTLSStreamErrorCode)errorCode { self = [super init]; @try { _stream = [stream retain]; _host = [host copy]; _errorCode = errorCode; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_stream release]; [_host release]; [super dealloc]; } - (OFString *)description { if (_host != nil) return [OFString stringWithFormat: @"TLS handshake in class %@ with host %@ failed: %@", _stream.class, _host, OFTLSStreamErrorCodeDescription(_errorCode)]; else return [OFString stringWithFormat: @"TLS handshake in class %@ failed: %@", _stream.class, OFTLSStreamErrorCodeDescription(_errorCode)]; } @end