将RSA公钥添加到Xamarin表格中的Android密钥店
我的应用程序使用RSA公钥在传递给服务器之前对数据进行加密。如果我将公共密钥嵌入解决方案并使用它,一切正常。
但是,我的客户有时希望更改此公共密钥,因此我无法将publicKey.key文件作为嵌入式资源添加到解决方案中。 我的第一个提示是,我应该像在设置下安装x509 cetificate一样,将此公钥安装到密钥库中 - >安全 - >在手机上安装用户证书方法。 此方法失败了,因为我的文件仅包含公共密钥,这不是证书。
如何将此公钥存储在密钥库中?我的目标是安装它,之后,想在我发布到服务器之前使用我的Xamarin Forms应用程序阅读它,以加密数据。
因此,我的目标不是用代码设置此公共密钥,而是必须在那里。
My application uses an RSA public key to encrypt the data before passed to the server. Everything works fine if I embed the public key to my solution and just use it.
However my client wants to change this public key sometimes, so I'm unable to add the PublicKey.key file to the solution as embedded resource.
My first tought was that I should install this public key to the Keystore like I install an X509Cetificate under the settings -> security -> Install user certificate method on the phone.
This method fails, because my file only contains the public key, which is not a certificate.
How can I store this public key in the Keystore? My goal is to install it, after that in would like to read it with my Xamarin Forms app in order to encrypt the data before I post to the server.
So my goal is not the set this public key to the keystore with code, it has to be there.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以尝试将公共密钥作为字符串保存到安全存储中。
要在安全存储中保存给定键的值:
从安全存储中检索值:
有关更多详细信息,请参阅Xamarin.Estentials:安全存储:
https:https://学习。 microsoft.com/en-us/xamarin/esentials/secure-storage?context=xamarin%2fandroid&tabs=ios
You could try to save public key as string into Secure Storage.
To save a value for a given key in secure storage:
To retrieve a value from secure storage:
For more details, refer to Xamarin.Essentials: Secure Storage:
https://learn.microsoft.com/en-us/xamarin/essentials/secure-storage?context=xamarin%2Fandroid&tabs=ios