微软说的 cross-platform...开发环境一言难尽

2020-11-24 19:09:32 +08:00
 fiveelementgid

微软说的 cross-platform,先不说部署的时候一堆奇怪的 bug,这 Linux 下的开发环境的手动配置真是 把人恶心炸了 用的是 Visual Studio Code

也有人问为啥不上 JetBrains 的 Rider

因为目前为止还不支持.net 5,本来就是冲着这个去的,EAP 据说 bug 也很多

Visual Studio Code 主要是做 C#和 ASP.NET Core,问题来了,他这个配置 develop certificate(self-signed)自签名证书。 微软的他推荐的一键命令: dotnet dev-certs https --trust ,但是这个在 VSC For Linux 下根本没用, 微软只有一句话:

See the documentation for your Linux distribution on how to trust the HTTPS development certificate.

微软生成的自签名证书,存在~/dotnet/corefx/cryptography/x509stores/([0-9A-F]+).pfx,查了一下,用 的是微软自己的 pkcs12 算法生成的......搞了一天也没查到去哪里导入..... 欸...开始怀疑自己是不是上错车了,每日骂微软 1/1

5117 次点击
所在节点    程序员
52 条回复
hjc4869
2020-11-24 19:12:42 +08:00
pkcs12 是标准格式吧… openssl 有支持的
secondwtq
2020-11-24 19:14:59 +08:00
PKCS12 是一种格式,不是一种算法 ...
LokiSharp
2020-11-24 19:15:03 +08:00
whywhywhy
2020-11-24 19:16:16 +08:00
现在刚学 .net ,到处都看到在说不管从什么角度都要转 java,心累,唉。
aloyuu
2020-11-24 19:18:57 +08:00
@whywhywhy 已经从 java 转到 C# ,建议不要入 JAVA
nannanziyu
2020-11-24 19:20:12 +08:00
1. 你好好问应该怎么做
自然会回答你。
2. 你起手就无能吐槽
那只能跟你说,安装个 pfx 证书搞了一天也没搞定?你改行吧,你解决问题的能力不适合编程
jiangzm
2020-11-24 19:22:32 +08:00
典型的拉不出屎来怪厕所不好👍
cxe2v
2020-11-24 19:28:37 +08:00
linux 不就是以可以自由配置而自豪地吗?
love
2020-11-24 19:38:49 +08:00
@whywhywhy 是什么支持你要选困难模式呢?千万别说是情怀。。。M$有个啥情怀
securityCoding
2020-11-24 19:42:48 +08:00
面向工资编程
fiveelementgid
2020-11-24 19:44:45 +08:00
@hjc4869 openssl 导出了 cert 和 key,也不知道咋导入.....

@secondwtq emmm 谢谢(• ▽ •;),有点表述错误

@LokiSharp 这个我昨天已经试过了,不行,我这是 fedora 33,你看那个最高赞的答案原本是 48,我昨天点赞成的 49.......
@whywhywhy .....心疼
@nannanziyu 啊这,稍等,我重新仔细问一遍
@jiangzm (ꏿ﹏ꏿ;)我错了,我重新问一遍
@cxe2v 是啊,但是配置不成功就很痛苦了
nannanziyu
2020-11-24 19:45:29 +08:00
@love
因为能挣钱可以吧
每个 dotnet 的帖子都见你来嘲讽下
zhuangzhuang1988
2020-11-24 19:46:53 +08:00
那就用 Java 呗, 反正不要钱
nannanziyu
2020-11-24 19:49:26 +08:00
@fiveelementgid
1. export pfx to pem
2. Copy the certificate pem to /etc/pki/ca-trust/source/anchors
3. Then run update-ca-trust
fiveelementgid
2020-11-24 19:55:47 +08:00
@cxe2v
@jiangzm
@nannanziyu
重新提问:VS Code 的证书存在于.dotnet/corefx/cryptography/x509stores/my/*********.pfx 下,我现在需要将 VSC 中 ASP.NET Core 中的 127.0.0.1 的 CA 证书加入可信任证书。
openssl pkcs12 -in ~/.dotnet/corefx/cryptography/x509stores/my/***************EA.pfx -out VSC.cert -nodes -nokeys 可以导出 VSC.cert
openssl pkcs12 -in ~/.dotnet/corefx/cryptography/x509stores/my/01*********0F8EA.pfx -out VSC.key -nodes -nocerts 可以导出 VSC.key
根据 https://stackoverflow.com/questions/55485511/how-to-run-dotnet-dev-certs-https-trust 所说调整,rpm 系 Linux 应该用`update-ca-trust`进行更新
根据 man update-ca-trust 文档
> QUICK HELP 1: To add a certificate in the simple PEM or DER file formats to the list
of CAs trusted on the system:

• add it as a new file to directory /etc/pki/ca-trust/source/anchors/

• run `update-ca-trust extract`

然后把上面得到的 VSC.cert 导入到 /etc/pki/ca-trust/source/anchors/里面,然后执行`update-ca-trust extract`,进去 127.0.0.1 还是 invalid certificate
求解决方案
woahishui
2020-11-24 19:59:51 +08:00
楼主不要急,慢慢解决
nannanziyu
2020-11-24 19:59:59 +08:00
@fiveelementgid
不确定,你先判断下是自签名证书信任未生效,还是浏览器没有信任
你 curl 127.0.0.1 试一下呢
fiveelementgid
2020-11-24 20:00:04 +08:00
@securityCoding
@zhuangzhuang1988 暂时不打算 Java,看看被吊打到啥时候吧.....


@nannanziyu export pfx to pem 我昨天也查了一下,参考了这个 https://www.sslshopper.com/ssl-converter.html,和上一楼我说的情况操作一样,依旧是无效
12101111
2020-11-24 20:04:56 +08:00
每一个 Linux 管理 openssl 默认密钥的方式都不一样,更何况还有 libressl 和 GNU TLS,这是 Linux 的优点也是缺点, 不会找 Linux 发行版的文档还怪微软没有水晶球不知道你在用哪个 Linux 发行版.
fiveelementgid
2020-11-24 20:10:19 +08:00
@woahishui 感谢

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/728829

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX