@@ -1524,8 +1524,7 @@ - (BOOL) trust
15241524 m = [NSMutableString stringWithCapacity: 2000 ];
15251525 for (i = 0 ; i < count; i++)
15261526 {
1527- [GSTLSCertificateList certInfo: crts[i]
1528- to: m];
1527+ [GSTLSCertificateList certInfo: crts[i] to: m];
15291528 }
15301529 if (0 == count)
15311530 {
@@ -2319,19 +2318,31 @@ - (NSString*) sessionInfo
23192318 {
23202319 unsigned int cert_list_size = 0 ;
23212320 const gnutls_datum_t *cert_list;
2322- gnutls_x509_crt_t cert;
23232321
23242322 cert_list = gnutls_certificate_get_peers (session, &cert_list_size);
2323+ [str appendString: @" - " ];
23252324 if (0 == cert_list_size)
23262325 {
2327- [str appendString: _ (@" - Peer provided no certificate.\n " )];
2326+ [str appendString: _ (@" Peer provided no certificate." )];
2327+ [str appendString: @" \n " ];
23282328 }
23292329 else
23302330 {
23312331 int cert_num;
23322332
2333+ if (cert_list_size > 1 )
2334+ {
2335+ [str appendString: _ (@" Peer certificates" )];
2336+ }
2337+ else
2338+ {
2339+ [str appendString: _ (@" Peer certificate" )];
2340+ }
2341+ [str appendString: @" \n " ];
23332342 for (cert_num = 0 ; cert_num < cert_list_size; cert_num++)
23342343 {
2344+ gnutls_x509_crt_t cert;
2345+
23352346 gnutls_x509_crt_init (&cert);
23362347 /* NB. the list of peer certificate is in memory in native
23372348 * format (DER) rather than the normal file format (PEM).
@@ -2373,6 +2384,7 @@ - (NSString*) sessionInfo
23732384- (int ) verify
23742385{
23752386 NSArray *names;
2387+ NSString *nameList;
23762388 NSString *str;
23772389 NSMutableString *ci;
23782390 unsigned int status;
@@ -2494,16 +2506,16 @@ - (int) verify
24942506 ci = [NSMutableString stringWithCapacity: 2000 ];
24952507 [GSTLSCertificateList certInfo: cert to: ci];
24962508
2497- str = [opts objectForKey: GSTLSRemoteHosts];
2498- if (nil == str )
2509+ nameList = [opts objectForKey: GSTLSRemoteHosts];
2510+ if (nil == nameList )
24992511 {
25002512 /* If nothing is specified, assume the connection host name
25012513 * (if any) should be used for verification.
25022514 */
2503- str = [opts objectForKey: GSTLSServerName];
2504- if ([str length ] > 0 )
2515+ nameList = [opts objectForKey: GSTLSServerName];
2516+ if ([nameList length ] > 0 )
25052517 {
2506- names = [NSArray arrayWithObject: str ];
2518+ names = [NSArray arrayWithObject: nameList ];
25072519 }
25082520 else
25092521 {
@@ -2515,7 +2527,7 @@ - (int) verify
25152527 /* The string is a comma separated list of permitted host names.
25162528 * If explicitly set to be empty, no host verification is done.
25172529 */
2518- names = [str componentsSeparatedByString: @" ," ];
2530+ names = [nameList componentsSeparatedByString: @" ," ];
25192531 if ([names count ] == 0 )
25202532 {
25212533 names = nil ;
@@ -2540,7 +2552,7 @@ - (int) verify
25402552 {
25412553 str = [NSString stringWithFormat:
25422554 @" TLS verification: hostname does not match '%@ ' in %@ " ,
2543- names , ci];
2555+ nameList , ci];
25442556 ASSIGN (problem, str);
25452557 gnutls_x509_crt_deinit (cert);
25462558 if (YES == debug) NSLog (@" %p %@ " , handle, problem);
0 commit comments