From: msweet Date: Tue, 19 May 2015 02:22:55 +0000 (+0000) Subject: Add TLS version. X-Git-Tag: v2.2b1~303 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=72b9a3131af06ce49232e5ed693fa58fc1f3ab9e;p=thirdparty%2Fcups.git Add TLS version. git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@12636 a1ca3aef-8c08-0410-bb20-df032aa958be --- diff --git a/cups/tlscheck.c b/cups/tlscheck.c index b3cd5a5956..05411cc5e5 100644 --- a/cups/tlscheck.c +++ b/cups/tlscheck.c @@ -34,6 +34,7 @@ main(int argc, /* I - Number of command-line arguments */ const char *server = argv[1]; /* Hostname from command-line */ int port = 631; /* Port number */ const char *cipherName = "UNKNOWN";/* Cipher suite name */ + int tlsVersion = 0; /* TLS version number */ if (argc < 2 || argc > 3) @@ -55,6 +56,7 @@ main(int argc, /* I - Number of command-line arguments */ } #ifdef __APPLE__ + SSLProtocol protocol; SSLCipherSuite cipher; char unknownCipherName[256]; int paramsNeeded = 0; @@ -62,6 +64,32 @@ main(int argc, /* I - Number of command-line arguments */ size_t paramsLen; OSStatus err; + if ((err = SSLGetNegotiatedProtocolVersion(http->tls, &protocol)) != noErr) + { + printf("%s: ERROR (No protocol version - %d)\n", server, (int)err); + httpClose(http); + return (1); + } + + switch (protocol) + { + default : + tlsVersion = 0; + break; + case kSSLProtocol3 : + tlsVersion = 30; + break; + case kTLSProtocol1 : + tlsVersion = 10; + break; + case kTLSProtocol11 : + tlsVersion = 11; + break; + case kTLSProtocol12 : + tlsVersion = 12; + break; + } + if ((err = SSLGetNegotiatedCipher(http->tls, &cipher)) != noErr) { printf("%s: ERROR (No cipher suite - %d)\n", server, (int)err); @@ -411,7 +439,7 @@ main(int argc, /* I - Number of command-line arguments */ } #endif /* __APPLE__ */ - printf("%s: OK (%s)\n", server, cipherName); + printf("%s: OK (%d.%d, %s)\n", server, tlsVersion / 10, tlsVersion % 10, cipherName); httpClose(http);