[105985] trunk/dports/security/certsync/files/certsync.m

landonf at macports.org landonf at macports.org
Sat May 11 21:12:46 PDT 2013


Revision: 105985
          https://trac.macports.org/changeset/105985
Author:   landonf at macports.org
Date:     2013-05-11 21:12:46 -0700 (Sat, 11 May 2013)
Log Message:
-----------
Additional fixes for 10.6.

Modified Paths:
--------------
    trunk/dports/security/certsync/files/certsync.m

Modified: trunk/dports/security/certsync/files/certsync.m
===================================================================
--- trunk/dports/security/certsync/files/certsync.m	2013-05-12 04:05:34 UTC (rev 105984)
+++ trunk/dports/security/certsync/files/certsync.m	2013-05-12 04:12:46 UTC (rev 105985)
@@ -192,8 +192,19 @@
     }
     
     for (id certObj in result) {
-        CFErrorRef cferror;
-        CFStringRef subject = SecCertificateCopyShortDescription(NULL, (SecCertificateRef) certObj, &cferror);
+        CFErrorRef cferror = NULL;
+        CFStringRef subject;
+
+#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_6
+        if (SecCertificateCopyShortDescription != NULL) {
+            subject = PLCFAutorelease(SecCertificateCopyShortDescription(NULL, (SecCertificateRef) certObj, &cferror));
+        } else {
+            subject = PLCFAutorelease(SecCertificateCopySubjectSummary((SecCertificateRef) certObj));
+        }
+#else
+        subject = PLCFAutorelease(SecCertificateCopySubjectSummary((SecCertificateRef) certObj));
+#endif
+
         if (subject == NULL) {
             nsfprintf(stderr, @"Failed to extract certificate description: %@\n", cferror);
             return EXIT_FAILURE;
@@ -216,7 +227,7 @@
         err = SecKeychainItemExport((CFArrayRef) anchors, kSecFormatPEMSequence, kSecItemPemArmour, NULL, &pemData);
     }
 #else
-    err = SecItemExport((CFArrayRef) anchors, kSecFormatPEMSequence, kSecItemPemArmour, NULL, &pemData);
+    err = SecKeychainItemExport((CFArrayRef) anchors, kSecFormatPEMSequence, kSecItemPemArmour, NULL, &pemData);
 #endif
     
     if (err != errSecSuccess) {
@@ -244,36 +255,40 @@
 }
 
 int main (int argc, char * const argv[]) {
-    @autoreleasepool {
-        /* Parse the command line arguments */
-        BOOL userAnchors = NO;
-        NSString *outputFile = nil;
-        
-        int ch;
-        while ((ch = getopt(argc, argv, "huo:")) != -1) {
-            switch (ch) {
-                case 'u':
-                    userAnchors = YES;
-                    break;
-                    
-                case 'o':
-                    outputFile = [NSString stringWithUTF8String: optarg];
-                    break;
+    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
 
-                case 'h':
-                    usage(argv[0]);
-                    exit(EXIT_SUCCESS);
+    /* Parse the command line arguments */
+    BOOL userAnchors = NO;
+    NSString *outputFile = nil;
+    
+    int ch;
+    while ((ch = getopt(argc, argv, "huo:")) != -1) {
+        switch (ch) {
+            case 'u':
+                userAnchors = YES;
+                break;
+                
+            case 'o':
+                outputFile = [NSString stringWithUTF8String: optarg];
+                break;
 
-                default:
-                    usage(argv[0]);
-                    exit(EXIT_FAILURE);
-            }
+            case 'h':
+                usage(argv[0]);
+                exit(EXIT_SUCCESS);
+
+            default:
+                usage(argv[0]);
+                exit(EXIT_FAILURE);
         }
-        argc -= optind;
-        argv += optind;
-        
-        /* Perform export  */
-        return exportCertificates(userAnchors, outputFile);
     }
+    argc -= optind;
+    argv += optind;
+    
+    /* Perform export  */
+    int ret = exportCertificates(userAnchors, outputFile);
+
+    [pool release];
+    
+    return ret;
 }
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20130511/7e447a28/attachment.html>


More information about the macports-changes mailing list