I am making a native ios module for yandexnavi. The module has been successfully created and I am passing geolocation data to it. Next, I use the code from the Yandex instructions. But I am getting an error - Fatal error: Unexpectedly found nil while unwrapping an Optional value. At the end of the function:
func loadCert() -> SecKey {
let certificateData = NSData(
contentsOf:Bundle.main.url(forResource: "private_key", withExtension: "der")!
)
let options: [String: Any] =
[kSecAttrKeyType as String: kSecAttrKeyTypeRSA,
kSecAttrKeyClass as String: kSecAttrKeyClassPrivate,
kSecAttrKeySizeInBits as String: 512]
let key = SecKeyCreateWithData(certificateData!,
options as CFDictionary,
nil)
return key! //Fatal error: Unexpectedly found nil while unwrapping an Optional value.
}
It seems that the key file is not correct, but if the resource file is not correct, then I get a completely different error
The sent Yandex key *.pen was previously converted to *.der
openssl rsa -in key.pem -out key.der -outform DER