gpt4 book ai didi

java - Tornado 从请求 header 读取 X509 证书

转载 作者:行者123 更新时间:2023-12-01 11:53:07 25 4
gpt4 key购买 nike

如何从进入 Tornado 服务器的 HTTP(S) 请求中读取 X509 证书? java中的类似代码:

public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException,
IOException {
res.setContentType("text/plain");
PrintWriter out = res.getWriter();

X509Certificate[] certs = (X509Certificate[]) req
.getAttribute("javax.servlet.request.X509Certificate");

最佳答案

RequestHandler 中,使用 self.request.get_ssl_certificate()。要使用此方法,您还必须在构建 HTTPServer 时在 ssl_options 中设置 cert_reqs 选项:

server = HTTPServer(app,
ssl_options=dict(
certfile="foo.crt",
keyfile="foo.key",
cert_reqs=ssl.CERT_REQUIRED,
ca_certs="cacert.crt"))

http://www.tornadoweb.org/en/stable/httputil.html#tornado.httputil.HTTPServerRequest.get_ssl_certificate

关于java - Tornado 从请求 header 读取 X509 证书,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28632541/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com