Ignore:
Timestamp:
Dec 16, 2013, 5:48:17 AM (5 years ago)
Author:
landonf@…
Message:

Remove use of SecCertificateGetSubject(); it was left unimplemented in 10.4, and has a broken header declaration.
With this, one-shot generation is working on Tiger.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dports/security/certsync/files/certsync-tiger.m

    r114814 r114815  
    151151}
    152152
    153 static NSString *getCommonName (const CSSM_X509_NAME *x509Name) {
    154     uint32 rdn_idx;
    155     uint32 pair_idx;
    156    
    157     for (rdn_idx = 0; rdn_idx < x509Name->numberOfRDNs; rdn_idx++) {
    158         CSSM_X509_RDN_PTR rdn = &x509Name->RelativeDistinguishedName[rdn_idx];
    159 
    160         for (pair_idx = 0; pair_idx < rdn->numberOfPairs; pair_idx++) {
    161             CSSM_X509_TYPE_VALUE_PAIR *pair = &rdn->AttributeTypeAndValue[pair_idx];
    162             if (!compare_oids(&pair->type, &CSSMOID_CommonName))
    163                 continue;
    164 
    165             switch (pair->valueType) {
    166                 case BER_TAG_PRINTABLE_STRING:
    167                 case BER_TAG_IA5_STRING:   
    168                 case BER_TAG_T61_STRING: {
    169                     return (NSString *) PLCFAutorelease(CFStringCreateWithBytes(NULL, pair->value.Data, pair->value.Length, kCFStringEncodingUTF8, false));
    170                     break;
    171                 }
    172                 default:
    173                     return nil;
    174             }
    175         }
    176     }
    177    
    178     return nil;
    179 }
    180 
    181153static int exportCertificates (NSString *outputFile) {
    182154    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     
    192164        [pool release];
    193165        return EXIT_FAILURE;
    194     }
    195    
    196     NSEnumerator *anchorEnumerator = [anchors objectEnumerator];
    197     id certObj;
    198     while ((certObj = [anchorEnumerator nextObject]) != nil) {
    199         NSError *error = NULL;
    200         const CSSM_X509_NAME *subject;
    201         NSString *commonName = nil;
    202 
    203         if ((err = SecCertificateGetSubject((SecCertificateRef) certObj, &subject)) == noErr) {
    204             commonName = getCommonName(subject);
    205         } else {
    206             NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys: @"SecCertificateGetSubject() failed", NSLocalizedDescriptionKey, nil];
    207             error = [NSError errorWithDomain: NSOSStatusErrorDomain code: err userInfo: userInfo];
    208         }
    209 
    210         if (commonName == nil) {
    211             nsfprintf(stderr, @"Failed to extract certificate description: %@\n", error);
    212         } else {
    213             nsfprintf(stderr, @"Found %@\n", commonName);
    214         }
    215166    }
    216167   
Note: See TracChangeset for help on using the changeset viewer.