2017-12-16 3 views
0

UIDocumentPickerViewControllerを使用してSSL証明書をインポートするにはどうすればよいですか?UIDocumentPickerViewControllerインポートSSL証明書

let documentPicker: UIDocumentPickerViewController = UIDocumentPickerViewController(documentTypes: ["public.item"], in: UIDocumentPickerMode.import) 
documentPicker.delegate = self 
documentPicker.modalPresentationStyle = .formSheet 

if #available(iOS 11.0, *) { 
    documentPicker.allowsMultipleSelection = false 
} 

UINavigationBar.appearance().tintColor = .green 
self.present(documentPicker, animated: true, completion: completion) 

しかし.cerファイルは、それを選択するために、常に無効です::

私はこのような何かやっている。また

cer disabled

を、私は、インポートする方法を見つけることができません拡張子のないファイル。

+0

が重複する可能性:https://stackoverflow.com/a/42142790/1361672 – RLoniello

+0

@ Ercell0それはまだ – pableiros

+0

あなたがファイルにアクセスしているという回答が動作していませんdidPickDocumentAtURLのurl.startAccessingSecurityScopedResource()およびurl.stopAccessingSecurityScopedResource()を使用して、NSFileCoordinatorを使用してファイルにアクセスすることもできます。 – RLoniello

答えて

0

これは私がそれを動作させる方法です。まず、私は、モバイルコアサービスをインポートする必要がありました:

import MobileCoreServices 

その後、これは私がUIDocumentPickerViewControllerをインスタンス化する方法である:

let types: NSArray = NSArray(object: kUTTypeX509Certificate as NSString) 
let documentPicker: UIDocumentPickerViewController = UIDocumentPickerViewController(documentTypes: types as! [String], in: UIDocumentPickerMode.import) 

ちなみに、私はそれがiCloud Driveで動作させる、そうでありませんバグによって明らかにGoogle Driveと連携:http://www.openradar.me/24187873