private async void LoadFromFile() { IsLoadingFile = true; try { var status = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Storage); if (status != PermissionStatus.Granted) { if (await CrossPermissions.Current.ShouldShowRequestPermissionRationaleAsync(Permission.Storage)) { await DisplayAlert("Need access storage", "It is nessecary for certificate loading.", "OK"); } var results = await CrossPermissions.Current.RequestPermissionsAsync(Permission.Storage); status = results[Permission.Storage]; } if (status == PermissionStatus.Denied) { await DisplayAlert("Error", "Storage permission is not granted.", "OK"); IsLoadingFile = false; return; } FileData fileData = await CrossFilePicker.Current.PickFile(); if (fileData == null) { IsLoadingFile = false; return; } X509Certificate2 cert = X509Certificate2Utils.ImportFromPkcs12(fileData.DataArray, true); app.AfterCertificateSelected(cert); } catch (Exception ex) { logger.LogException(this, ex); await DisplayAlert("Error", "Certificate loading failed.", "OK"); IsLoadingFile = false; } }