Note that there are some explanatory texts on larger screens.

plurals
  1. POcreateKeychainValue from a NSString
    primarykey
    data
    text
    <p>I'm trying to add a certificate to the keychain. I saw several posts that make this from a file, but I want to create one from a NSString.</p> <p>My NSString is on RSA - 64base and is like:</p> <pre><code>-----BEGIN CERTIFICATE----- MIIDoDCCAoigAwIBAgIJAL8qgXMVVVhPMA0GCSqGSIb3DQEBBQUAMGwxCzAJBgNVBAYTAkJSMRIw ... FT70at8bty9ocDaXuI3j6mfw2SI= -----END CERTIFICATE----- </code></pre> <p>And I'm trying to do something like this:</p> <pre><code>+ (NSMutableDictionary *)newSearchDictionary:(NSString *)identifier { NSMutableDictionary *searchDictionary = [[NSMutableDictionary alloc] init]; [searchDictionary setObject:(__bridge id)kSecClassCertificate forKey:(__bridge id)kSecClass]; NSData *encodedIdentifier = [identifier dataUsingEncoding:NSUTF8StringEncoding]; [searchDictionary setObject:encodedIdentifier forKey:(__bridge id)kSecAttrGeneric]; [searchDictionary setObject:encodedIdentifier forKey:(__bridge id)kSecAttrAccount]; [searchDictionary setObject:SERVICE_NAME forKey:(__bridge id)kSecAttrService]; return searchDictionary; } + (BOOL)createKeychainValue:(NSString *)certificado forIdentifier:(NSString *)identifier { NSMutableDictionary *dictionary = [self newSearchDictionary:identifier]; NSData *certificadoData = [certificado dataUsingEncoding:NSUTF8StringEncoding]; SecCertificateRef cert = SecCertificateCreateWithData(NULL, (__bridge CFDataRef) certificadoData); [dictionary setObject:(__bridge id)(cert) forKey:(__bridge id&lt;NSCopying&gt;)(kSecValueRef)]; OSStatus status = SecItemAdd((__bridge CFDictionaryRef)dictionary, NULL); CFRelease(cert); if (status == errSecSuccess) { return YES; } return NO; } </code></pre> <p>But is getting back the cert as nil. Probably because my certificate is PEM and I need a DER. How can I convert? I'm using openssl on my project.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload