File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -56,6 +56,11 @@ GS_EXPORT NSString * const GSTLSVerify;
5656#endif
5757#undef id
5858
59+ /* * Notification posted whenever a connection (handled by a [GSTLSSession]
60+ * instance) to a TLS server fails certificate or host name verification.
61+ */
62+ GS_EXPORT NSString * const GSTLSVerifyFailedNotification;
63+
5964/* This class is used to ensure that the GNUTLS system is initialised
6065 * and thread-safe. It also provides a mechanism to save certificate
6166 * and key information in memory by associating a 'filename' with the
@@ -254,12 +259,21 @@ GS_EXPORT_CLASS
254259 */
255260- (BOOL ) handshake ;
256261
262+ /* * Returns the name of the host this session connects to, or nil if it
263+ * is not to a named host.
264+ */
265+ - (NSString *) hostName ;
266+
257267/* * If the session verified a certificate from the remote end, returns the
258268 * name of the certificate issuer in the form "C=xxxx,O=yyyy,CN=zzzz" as
259269 * described in RFC4514. Otherwise returns nil.
260270 */
261271- (NSString *) issuer ;
262272
273+ /* * Returns the configured options for this session.
274+ */
275+ - (NSDictionary *) options ;
276+
263277/* * If the session verified a certificate from the remote end, returns the
264278 * name of the certificate owner in the form "C=xxxx,O=yyyy,CN=zzzz" as
265279 * described in RFC4514. Otherwise returns nil.
Original file line number Diff line number Diff line change 4343
4444#import " GSPrivate.h"
4545
46+ NSString * const GSTLSVerifyFailedNotification
47+ = @" GSTLSVerifyFailedNotification" ;
48+
4649@interface NSString (gnutlsFileSystemRepresentation)
4750- (const char *) gnutlsFileSystemRepresentation ;
4851@end
@@ -1648,6 +1651,15 @@ - (void) finalize
16481651 [super finalize ];
16491652}
16501653
1654+ - (NSString *) hostName
1655+ {
1656+ if (outgoing)
1657+ {
1658+ return [opts objectForKey: GSTLSServerName];
1659+ }
1660+ return nil ;
1661+ }
1662+
16511663- (id ) initWithOptions : (NSDictionary *)options
16521664 direction : (BOOL )isOutgoing
16531665 transport : (void *)ioHandle
@@ -2047,6 +2059,12 @@ - (BOOL) handshake
20472059 handle, gnutls_strerror (ret));
20482060 NSLog (@" %p failed verify:\n %@ " , handle, [self sessionInfo ]);
20492061 }
2062+ if (outgoing)
2063+ {
2064+ [[NSNotificationCenter defaultCenter ]
2065+ postNotificationName: GSTLSVerifyFailedNotification
2066+ object: self ];
2067+ }
20502068 if (requireVerified)
20512069 {
20522070 [self disconnect: NO ];
@@ -2068,6 +2086,11 @@ - (NSString*) issuer
20682086 return issuer;
20692087}
20702088
2089+ - (NSDictionary *) options
2090+ {
2091+ return opts;
2092+ }
2093+
20712094- (NSString *) owner
20722095{
20732096 return owner;
Original file line number Diff line number Diff line change @@ -100,6 +100,7 @@ - (void)stream: (NSStream *)theStream handleEvent: (NSStreamEvent)streamEvent
100100 {
101101 NSAssert1 (1 , @" Error! code is %ld " ,
102102 (long int )[[theStream streamError] code]);
103+ done = YES ;
103104 break ;
104105 }
105106 }
You can’t perform that action at this time.
0 commit comments