You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to use the following code snippet, i am trying to use this for mobile device
var publicKey = """
-----BEGIN PUBLIC KEY-----
MMKCASI......xxxxxxxx
-----END PUBLIC KEY-----
""";
var keyData = PemCodec(PemLabel.publicKey).decode(publicKey);
var key = await RsaOaepPublicKey.importSpkiKey(
keyData,
Hash.sha256,
);
I am getting the following exception : FormatException: error:06000066:public key routines:OPENSSL_internal:DECODE_ERROR
Any suggestion if i missed anything or anything wrong in the approach?
The text was updated successfully, but these errors were encountered:
The issue likely lies in the format of your public key.
Could you please share the steps you took to generate this key.
Or could you run your key through the ASN.1 JavaScript decoder and share the entire link.
For some context; the public key we feed to importSpkiKey needs to be an RSA key in the SPKI format.
The DECODE_ERROR suggests that this might not be the case for this snippet.
Could you try generating the private key and then deriving the public key using OpenSSL:
Make sure the value passed to the -algorithm flag is RSA. The resulting key in the file pubk.pem should solve your issue.
Just for caution, could you also verify if your key began with -----BEGIN RSA PUBLIC KEY----- and you manually replaced the inner content of the PEM block?
I've created a test public key in the SPKI format where this issue does not exist, you may find it in this Gist. Here is the ASN.1 Decoding for the same. This may help!
Actually, the public key i get it from server.. as it is working for web app, in web they are using angular, and using window.crypto.subtle.importKey, i thought to replicate the similar logic on mobile app, but got this error.. Upon investigation, i found, for mobile app, package ffi was used from lib/src/impl_ffi/impl_ffi.rsaoaep.dart,
and not the js package, i.e lib/src/impl_js/impl_js.rsaoaep.dart
So for now, we had made some workaround for this..
Hello,
I am trying to use the following code snippet, i am trying to use this for mobile device
I am getting the following exception :
FormatException: error:06000066:public key routines:OPENSSL_internal:DECODE_ERROR
Any suggestion if i missed anything or anything wrong in the approach?
The text was updated successfully, but these errors were encountered: