public void InstallIntoKeyChain(X509Certificate certificate) { var provider = DependencyInjector.Get <ICertificateProvider> (); string password; var data = provider.GetRawCertificateData(certificate, out password); using (var identity = SecIdentity.Import(data, password)) { SecKeyChain.AddIdentity(identity); } }
public override void WillSendRequestForAuthenticationChallenge(NSUrlConnection connection, NSUrlAuthenticationChallenge challenge) { var identity = SecIdentity.Import(Certificate); var certificate = new SecCertificate(Certificate); SecCertificate[] certificates = { certificate }; var credential = NSUrlCredential.FromIdentityCertificatesPersistance(identity, certificates, NSUrlCredentialPersistence.ForSession); challenge.Sender.UseCredential(credential, challenge); }
public static SecIdentity GetIdentity(X509Certificate certificate) { /* * If we got an 'X509Certificate2', then we require it to have a private key * and import it. */ var certificate2 = certificate as X509Certificate2; if (certificate2 != null) { return(SecIdentity.Import(certificate2)); } /* * Otherwise, we require the private key to be in the keychain. */ using (var secCert = new SecCertificate(certificate)) { return(SecKeyChain.FindIdentity(secCert, true)); } }