]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Save work...
authormsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Thu, 12 Dec 2013 17:55:04 +0000 (17:55 +0000)
committermsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Thu, 12 Dec 2013 17:55:04 +0000 (17:55 +0000)
git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@11458 a1ca3aef-8c08-0410-bb20-df032aa958be

cups/tls-darwin.c

index baaccdd28af9f38d05c4f0585b20b5b0d45f925d..2d341f1804deaa182fa5b2b3a50e4714c269c5f2 100644 (file)
 extern char **environ;
 
 
+/*
+ * Local globals...
+ */
+
+static _cups_mutex_t   tls_mutex = _CUPS_MUTEX_INITIALIZER;
+                                       /* Mutex for keychain/certs */
+static SecKeychainRef  tls_keychain = NULL;
+                                       /* Server cert keychain */
+static int             tls_auto_create = 0;
+                                       /* Auto-create self-signed certs? */
+static char            *tls_common_name = NULL;
+                                       /* Default common name */
+
+
 /*
  * Local functions...
  */
@@ -75,11 +89,38 @@ cupsSetServerCredentials(
     const char *common_name,           /* I - Default common name for server */
     int        auto_create)            /* I - 1 = automatically create self-signed certificates */
 {
-  (void)path;
-  (void)common_name;
-  (void)auto_create;
+  SecKeychainRef       keychain = NULL;/* Temporary keychain */
 
-  return (0);
+
+  if (SecKeychainOpen(path, &keychain) != noErr)
+  {
+    /* TODO: Set cups last error string */
+    return (0);
+  }
+
+  _cupsMutexLock(&tls_mutex);
+
+ /*
+  * Close any keychain that is currently open...
+  */
+
+  if (tls_keychain)
+    CFRelease(tls_keychain);
+
+  if (tls_common_name)
+    _cupsStrFree(tls_common_name);
+
+ /*
+  * Save the new keychain...
+  */
+
+  tls_keychain    = keychain;
+  tls_auto_create = auto_create;
+  tls_common_name = _cupsStrAlloc(common_name);
+
+  _cupsMutexUnlock(&tls_mutex);
+
+  return (1);
 }