net6 API 程序如何发布成https

1、打开IIS → 服务器证书 → 创建自签名证书

2、网站 → 绑定 → 添加绑定 → https → 在ssl中选择刚创建的证书

3、cmd测试:curl -k https://127.0.0.1/home

如果报错SEC_E_WRONG_PRINCIPAL (0x80090322) - 目标主要名称不正确
说明证书不被认可,跳过证书检查,需要加上-k

4、测试:curl -k -v https://127.0.0.1/home

加上 -v 可以查看运行的详细过程 ,详细信息如下

*   Trying 127.0.0.1:443...
* Connected to 127.0.0.1 (127.0.0.1) port 443 (#0)
* schannel: disabled automatic use of client certificate
* schannel: using IP address, SNI is not supported by OS.
* schannel: ALPN, offering http/1.1
* schannel: ALPN, server accepted to use http/1.1
> GET /home HTTP/1.1
> Host: 127.0.0.1
> User-Agent: curl/7.79.1
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Transfer-Encoding: chunked
< Content-Type: application/json; charset=utf-8
< Server: Microsoft-IIS/10.0
< Date: Tue, 27 Sep 2022 12:55:44 GMT
<
[{"date":"2022-09-28T20:55:44.8328594+08:00","temperatureC":35,"temperatureF":94,"summary":"Cool"},{"date":"2022-09-29T20:55:44.8328693+08:00","temperatureC":1,"temperatureF":33,"summary":"Sweltering"},{"date":"2022-09-30T20:55:44.8328705+08:00","temperatureC":36,"temperatureF":96,"summary":"Warm"},{"date":"2022-10-01T20:55:44.8328718+08:00","temperatureC":40,"temperatureF":103,"summary":"Chilly"},{"date":"2022-10-02T20:55:44.8328728+08:00","temperatureC":25,"temperatureF":76,"summary":"Freezing"}]
* Connection #0 to host 127.0.0.1 left intact

4、如果强制要求https,则 网站 → SSL设置 → 要求SSL证书 → 应用
如果程序添加app.UseHttpsRedirection(); 则会自动转发成https。

5、微信小程序不承认自己颁发的证书,可以去阿里云免费申请一年的SSL

https://yundun.console.aliyun.com/
posted @ 2022-09-27 21:26  his365  阅读(458)  评论(0编辑  收藏  举报