Author: rfm Date: Fri Sep 2 10:56:09 2016 New Revision: 40068 URL: http://svn.gna.org/viewcvs/gnustep?rev=40068&view=rev Log: improve certificate debug output
Modified: libs/base/trunk/Source/GSTLS.m Modified: libs/base/trunk/Source/GSTLS.m URL: http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Source/GSTLS.m?rev=40068&r1=40067&r2=40068&view=diff ============================================================================== --- libs/base/trunk/Source/GSTLS.m (original) +++ libs/base/trunk/Source/GSTLS.m Fri Sep 2 10:56:09 2016 @@ -564,59 +564,6 @@ unsigned int bits; int i; - [str appendFormat: @"\n%@", _(@"- Certificate info:\n")]; - - expiret = gnutls_x509_crt_get_expiration_time(cert); - activet = gnutls_x509_crt_get_activation_time(cert); - [str appendFormat: _(@"- Certificate is valid since: %s"), - ctime(&activet)]; - [str appendFormat: _(@"- Certificate expires: %s"), - ctime (&expiret)]; - -#if 0 -{ - char digest[20]; - size_t digest_size = sizeof(digest); - if (gnutls_x509_fingerprint(GNUTLS_DIG_MD5, - &cert_list[0], digest, &digest_size) >= 0) - { - [str appendString: _(@"- Certificate fingerprint: ")]; - for (i = 0; i < digest_size; i++) - { - [str appendFormat: @"%.2x ", (unsigned char)digest[i]]; - } - [str appendString: @"\n"]; - } -} -#endif - - if (gnutls_x509_crt_get_serial(cert, serial, &serial_size) >= 0) - { - [str appendString: _(@"- Certificate serial number: ")]; - for (i = 0; i < serial_size; i++) - { - [str appendFormat: @"%.2x ", (unsigned char)serial[i]]; - } - [str appendString: @"\n"]; - } - - [str appendString: _(@"- Certificate public key: ")]; - algo = gnutls_x509_crt_get_pk_algorithm(cert, &bits); - if (GNUTLS_PK_RSA == algo) - { - [str appendString: _(@"RSA\n")]; - [str appendFormat: _(@"- Modulus: %d bits\n"), bits]; - } - else if (GNUTLS_PK_DSA == algo) - { - [str appendString: _(@"DSA\n")]; - [str appendFormat: _(@"- Exponent: %d bits\n"), bits]; - } - else - { - [str appendString: _(@"UNKNOWN\n")]; - } - [str appendFormat: _(@"- Certificate version: #%d\n"), gnutls_x509_crt_get_version(cert)]; @@ -631,6 +578,56 @@ dn[dn_size - 1] = '\0'; [str appendFormat: _(@"- Certificate Issuer's DN: %@\n"), [NSString stringWithUTF8String: dn]]; + + activet = gnutls_x509_crt_get_activation_time(cert); + [str appendFormat: _(@"- Certificate is valid since: %s"), + ctime(&activet)]; + + expiret = gnutls_x509_crt_get_expiration_time(cert); + [str appendFormat: _(@"- Certificate expires: %s"), + ctime (&expiret)]; + +#if 0 +{ + char digest[20]; + size_t digest_size = sizeof(digest); + if (gnutls_x509_fingerprint(GNUTLS_DIG_MD5, + &cert_list[0], digest, &digest_size) >= 0) + { + [str appendString: _(@"- Certificate fingerprint: ")]; + for (i = 0; i < digest_size; i++) + { + [str appendFormat: @"%.2x ", (unsigned char)digest[i]]; + } + [str appendString: @"\n"]; + } +} +#endif + + if (gnutls_x509_crt_get_serial(cert, serial, &serial_size) >= 0) + { + [str appendString: _(@"- Certificate serial number: ")]; + for (i = 0; i < serial_size; i++) + { + [str appendFormat: @"%.2x ", (unsigned char)serial[i]]; + } + [str appendString: @"\n"]; + } + + [str appendString: _(@"- Certificate public key: ")]; + algo = gnutls_x509_crt_get_pk_algorithm(cert, &bits); + if (GNUTLS_PK_RSA == algo) + { + [str appendFormat: _(@"RSA - Modulus: %d bits\n"), bits]; + } + else if (GNUTLS_PK_DSA == algo) + { + [str appendFormat: _(@"DSA - Exponent: %d bits\n"), bits]; + } + else + { + [str appendString: _(@"UNKNOWN\n")]; + } } /* Method to purge older lists from cache. @@ -2006,7 +2003,6 @@ gnutls_x509_crt_import(cert, &cert_list[cert_num], GNUTLS_X509_FMT_DER); - [str appendString: @"\n"]; [str appendFormat: _(@"- Certificate %d info:\n"), cert_num]; [GSTLSCertificateList certInfo: cert to: str]; _______________________________________________ Gnustep-cvs mailing list Gnustep-cvs@gna.org https://mail.gna.org/listinfo/gnustep-cvs