5 // Created by Jens Alfke on 5/14/08.
6 // Copyright 2008 Jens Alfke. All rights reserved.
9 #import "TCPEndpoint.h"
11 #import "CollectionUtils.h"
12 #import "ExceptionUtils.h"
13 #import <Security/Security.h>
16 NSString* const kTCPPropertySSLClientSideAuthentication = @"kTCPPropertySSLClientSideAuthentication";
19 @implementation TCPEndpoint
24 [_sslProperties release];
29 - (NSMutableDictionary*) SSLProperties {return _sslProperties;}
31 - (void) setSSLProperties: (NSMutableDictionary*)props
33 if( props != _sslProperties ) {
34 [_sslProperties release];
35 _sslProperties = [props mutableCopy];
39 - (void) setSSLProperty: (id)value forKey: (NSString*)key
42 if( ! _sslProperties )
43 _sslProperties = [[NSMutableDictionary alloc] init];
44 [_sslProperties setObject: value forKey: key];
46 [_sslProperties removeObjectForKey: key];
49 - (NSString*) securityLevel {return [_sslProperties objectForKey: (id)kCFStreamSSLLevel];}
50 - (void) setSecurityLevel: (NSString*)level {[self setSSLProperty: level forKey: (id)kCFStreamSSLLevel];}
52 - (void) setPeerToPeerIdentity: (SecIdentityRef)identity {
54 self.SSLProperties = $mdict(
55 {(id)kCFStreamSSLLevel, NSStreamSocketSecurityLevelTLSv1},
56 {kTCPPropertySSLCertificates, $array((id)identity)},
57 {kTCPPropertySSLAllowsAnyRoot, $true},
58 {kTCPPropertySSLPeerName, [NSNull null]},
59 {kTCPPropertySSLClientSideAuthentication, $object(kTCPAlwaysAuthenticate)});
62 - (void) tellDelegate: (SEL)selector withObject: (id)param
64 if( [_delegate respondsToSelector: selector] ) {
66 [_delegate performSelector: selector withObject: self withObject: param];
67 }catchAndReport(@"%@ delegate",self.class);
76 Copyright (c) 2008, Jens Alfke <jens@mooseyard.com>. All rights reserved.
78 Redistribution and use in source and binary forms, with or without modification, are permitted
79 provided that the following conditions are met:
81 * Redistributions of source code must retain the above copyright notice, this list of conditions
82 and the following disclaimer.
83 * Redistributions in binary form must reproduce the above copyright notice, this list of conditions
84 and the following disclaimer in the documentation and/or other materials provided with the
87 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
88 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
89 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRI-
90 BUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
91 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
92 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
93 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
94 THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.