Xamarin iOS: Failed to save PKCS12 data in iOS keychain

Use Case:

The application imports the PKCS 12 file (with certificate and private key) and saves it for later use.

Current state:

I managed to use SecImportExport.ImportPkcs12 to get SecIdentity and SecTrust objects. Unfortunately, Im failed to assign a SecIdentity and SecTrust object to SecRecord.

Code:

SecIdentity identityObject = ...; SecTrust trustObject = ...; SecRecord record = new SecRecord(SecKind.Identity); record.Account = "Identity"; record.ValueData = ? //HOW TO CONVERT SecIdentity to NSData? var res = SecKeyChain.Add(record); 
+5
source share
1 answer

You can use SecRecord.SetValueRef (identityObject) , which can be used to store keys ( SecKey ), certificates ( SecCertificate ) or identities.

+1
source

All Articles