我正在开发一个使用HttpListener
类托管Web服务器的Android应用程序。
但是我需要使用SSL
证书来托管它,我已经在某处读过你需要将证书放在Android设备上的特殊目录中。
但我已经失去了指定确切位置的链接。
那么有谁知道如何让HTTPS
使用Xamarin
类在HttpListener
Android上工作?
编辑:我已经厌倦了如.cer
所建议的那样在.pvk
下存储Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), ".mono", "httplistener")
和HttpListener with HTTPS on MonoTouch文件但是当我尝试访问网址时我得不到答案,如果我更改为http i至少得到答案。
我在github上找到了以下源代码,https://github.com/mono/mono/blob/3f779475e3fc982e312212d5dbbd86515eddfc0c/mcs/class/System/System.Net/HttpListener.Mono.cs#L73
但它只是吃任何发生的异常,所以没有办法弄清楚是否有任何问题!
你没有说明你正在调用文件本身,看看System.Net.HttpListener的单声道代码,文件本身必须是{port number} .cer,即443,如果你要听443。
string dirname = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
string path = Path.Combine(dirname, ".mono");
path = Path.Combine(path, "httplistener");
string cert_file = Path.Combine(path, String.Format("{0}.cer", port));