简体   繁体   English

我应该在rails应用程序中本地测试SSL / HTTPS路由吗?

[英]should I test SSL / HTTPS routes locally in a rails app?

I'm wondering what the best practice is concerning test that certain urls use certain protocols. 我想知道关于测试的最佳实践是什么,某些网址使用某些协议。 Do I have to set up an SSL cert locally? 我是否必须在本地设置SSL证书?

You don't need to set up an SSL cert locally. 您无需在本地设置SSL证书。 You can fake an HTTPS request in your tests with something like: 您可以在测试中伪造HTTPS请求,例如:

request.env['HTTPS'] = 'on'

If your concern is specifically about HTTPS connections testing, I would suggest setting up your own test CA and issuing certificates for your machine. 如果您特别关注HTTPS连接测试,我建议您设置自己的测试CA并为您的计算机颁发证书。 Then, import the CA certificate into your test clients. 然后,将CA证书导入测试客户端。 This will be far more realistic than tests where you would just bypass the certificate verification. 这将比您绕过证书验证的测试更加真实。

Avoid certificates issued to IP addresses, give names to your servers. 避免颁发颁发给IP地址的证书,为您的服务器命名。 Even if you don't have a DNS server, set the machine names in the hosts files of the client machines. 即使您没有DNS服务器,也请在客户端计算机的hosts文件中设置计算机名称。

There are a number of tools that can help you set up a small CA. 有许多工具可以帮助您设置一个小型CA. TinyCA is one of them, for example. 例如,TinyCA就是其中之一。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM