dongqianchi0512 2017-01-31 17:00
浏览 228
已采纳

如何在Golang中编写HTTP服务器无证书?

I am trying to write a server logic which takes 'https' request but client does not have any certificate, how do I write it?

  • 写回答

2条回答 默认 最新

  • duanhe1903 2017-01-31 17:33
    关注

    This could go two different directions depending on what you're actually asking.

    If you're asking how to host https requests without the server having a certificate, that's impossible. https requests mean that the connection is secured by SSL/TLS, which necessarily requires a server certificate to function.

    If you're asking how to host https requests without requiring clients to have certificates, that's another matter, and in fact is the default behavior of the http.Server. You actually have to set the https.Server field ClientAuth (for example, to http.RequireAndVerifyClientCert) in order to actually require those certs. If you don't set this field, the default value is http.NoClientCert, which allows client connections without certificates, and doesn't validate the certs even if they are presented.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?