]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Add TLS version.
authormsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Tue, 19 May 2015 02:22:55 +0000 (02:22 +0000)
committermsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Tue, 19 May 2015 02:22:55 +0000 (02:22 +0000)
git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@12636 a1ca3aef-8c08-0410-bb20-df032aa958be

cups/tlscheck.c

index b3cd5a5956d4b02d2d40c5a18998cce48e2ef81b..05411cc5e59bd71e1d65ecd1ab6aff80cce889ba 100644 (file)
@@ -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);