【问题标题】:verify ssl certificate to authenticate the services accessing our private api?验证 ssl 证书以验证访问我们私有 api 的服务?
【发布时间】:2023-03-17 22:13:01
【问题描述】:


我们有一个网络服务和 3 个内部客户端访问它。
它们都托管在同一个域上,我们对它们都使用 ssl 证书 *.ourdomain.com。

所以我们得到了:

我想知道我们是否可以仅通过验证证书来验证请求的身份(在 api 上)。所以我们可以丢弃基本身份验证。

您认为它可行且安全吗?如何 ?我们在 rails 3.0.5 / ruby​​ 1.9.2

【问题讨论】:

    标签: ruby-on-rails ruby api ssl rack


    【解决方案1】:

    谁在您的环境中控制您的 SSL 终止? 如果你使用EventMachine,你可以在post_init里面使用

    def post_init
        start_tls :private_key_file => 'mycert', :cert_chain_file => 'mychain', :verify_peer => true 
    end
    

    然后在回调中你可以检查证书的有效性

      def ssl_verify_peer(cert)
        #TODO: check if the client cert is valid
      end
    

    从安全的角度来看,检查客户端 ssl 证书的有效性是可以的。你只需要保守秘密。如果有人窃取该文件,则将绕过身份验证。这就是为什么使用证书+密码(两因素身份验证)是一种上帝的做法。

    问候。

    【讨论】:

      猜你喜欢
      • 2012-11-14
      • 2015-06-24
      • 1970-01-01
      • 1970-01-01
      • 2017-06-13
      • 2019-03-29
      • 2018-12-07
      • 1970-01-01
      • 2019-01-26
      相关资源
      最近更新 更多