我使用此代码安装自签名证书(用户必须确认安装)。
// Constructor
public MainPage()
{
this.Loaded += new RoutedEventHandler(MainPage_Loaded);
}
private async void MainPage_Loaded(object sender, RoutedEventArgs e)
{
try
{
StorageFolder packageLocation = Windows.ApplicationModel.Package.Current.InstalledLocation;
StorageFolder certificateFolder = await packageLocation.GetFolderAsync("Certificates");
StorageFile certificate = await certificateFolder.GetFileAsync("myCer.cer");
await Launcher.LaunchFileAsync(certificate);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
}
是否可以检查证书是否已安装,以便我不必在每次启动应用程序时都安装它?