我有一个使用此代码安装的 x509 证书:
var certificate = AssetManagement.GetCertificate (xdoc); //this is a helper class that retrieves the certificate
//Code to install to keychain
Intent intent = KeyChain.CreateInstallIntent ();
intent.PutExtra (KeyChain.ExtraCertificate, certificate.GetRawCertData());
intent.PutExtra (KeyChain.ExtraName, "AzureManagement");
StartActivity (intent);
该代码成功调用android UI 安装证书并强制用户设置PIN 以保护设备。这很好用。
但是当我尝试像这样访问钥匙串时:
var chain = KeyChain.GetCertificateChain (this, "My cert alias");
我收到以下错误:Java.Lang.IllegalStateException: calling this from your main thread can lead to deadlock
访问钥匙串的正确方法是什么?