]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Don't use numeric hostnames for certificates (always a hostname).
authormsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Wed, 19 Feb 2014 16:36:17 +0000 (16:36 +0000)
committermsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Wed, 19 Feb 2014 16:36:17 +0000 (16:36 +0000)
git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@11612 a1ca3aef-8c08-0410-bb20-df032aa958be

cups/tls-darwin.c

index 0344a8b14994ede19688bd03821537b012f24dfe..71895b8241d52c10fe94057ef9edc2dfd816d0b2 100644 (file)
@@ -269,6 +269,8 @@ cupsSetServerCredentials(
     const char *common_name,           /* I - Default common name for server */
     int        auto_create)            /* I - 1 = automatically create self-signed certificates */
 {
+  DEBUG_printf(("cupsSetServerCredentials(path=\"%s\", common_name=\"%s\", auto_create=%d)", path, common_name, auto_create));
+
 #ifdef HAVE_SECKEYCHAINOPEN
   SecKeychainRef       keychain = NULL;/* Temporary keychain */
 
@@ -276,6 +278,7 @@ cupsSetServerCredentials(
   if (SecKeychainOpen(path, &keychain) != noErr)
   {
     /* TODO: Set cups last error string */
+    DEBUG_puts("1cupsSetServerCredentials: Unable to open keychain, returning 0.");
     return (0);
   }
 
@@ -305,9 +308,11 @@ cupsSetServerCredentials(
 
   _cupsMutexUnlock(&tls_mutex);
 
+  DEBUG_puts("1cupsSetServerCredentials: Opened keychain, returning 1.");
   return (1);
 
 #else
+  DEBUG_puts("1cupsSetServerCredentials: No keychain support compiled in, returning 0.");
   return (0);
 #endif /* HAVE_SECKEYCHAINOPEN */
 }
@@ -1212,10 +1217,16 @@ http_tls_start(http_t *http)            /* I - HTTP connection */
       else if (httpAddrLocalhost(&addr))
        hostname[0] = '\0';
       else
-       httpAddrString(&addr, hostname, sizeof(hostname));
+      {
+       httpAddrLookup(&addr, hostname, sizeof(hostname));
+        DEBUG_printf(("4http_tls_start: Resolved socket address to \"%s\".", hostname));
+      }
     }
 
 #ifdef HAVE_SECKEYCHAINOPEN
+    if (isdigit(hostname[0] & 255) || hostname[0] == '[')
+      hostname[0] = '\0';              /* Don't allow numeric addresses */
+
     if (hostname[0])
       http->tls_credentials = http_cdsa_copy_server(hostname);
     else if (tls_common_name)