![](/img/trans.png)
[英]Mono HTTPListener throws exception when using self signed SSL certificate
[英]Android HttpListener using SSL?
我正在開發一個使用HttpListener
類托管網絡服務器的android應用。
但是我需要使用SSL
證書來托管它,我已經讀過一些地方,您需要將證書放在android設備上的特殊目錄中。
但是我丟失了指定確切位置的鏈接。
那么,有人知道如何通過HttpListener
類使HTTPS
在Xamarin
Android上運行嗎?
編輯:我已經厭倦了將.cer
和.pvk
文件存儲在Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), ".mono", "httplistener")
如在Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), ".mono", "httplistener")
中使用HTTPS的HttpListener中所建議的,但是當我嘗試訪問該URL,但如果我更改為http,我至少沒有答案。
我在github上找到了以下源代碼, https://github.com/mono/mono/blob/3f779475e3fc982e312212d5dbbd86515eddfc0c/mcs/class/System/System.System/Net/HttpListener.Mono.cs#L73
但是它只會吞噬所有發生的異常,因此無法找出是否出了問題!
您沒有指出要調用的文件本身,而是查看System.Net.HttpListener的單聲道代碼,文件本身必須是{port number} .cer,即443.cer(如果您要偵聽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));
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.