gpt4 book ai didi

java - 为什么jetty服务器在发送请求时不同意协议(protocol)?

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

Java版本

1.8

Jetty版本

9.3.x

  • Trying :13443...
  • TCP_NODELAY set
  • Connected to (10.61.45.225) port 13443 (#0)
  • ALPN, offering http/1.1
  • Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
  • successfully set certificate verify locations:
  • CAfile: /etc/pki/tls/certs/ca-bundle.crt CApath: none
  • TLSv1.2 (OUT), TLS header, Certificate Status (22):
  • TLSv1.2 (OUT), TLS handshake, Client hello (1):
  • TLSv1.2 (IN), TLS handshake, Server hello (2):
  • TLSv1.2 (IN), TLS handshake, Certificate (11):
  • TLSv1.2 (IN), TLS handshake, Server key exchange (12):
  • TLSv1.2 (IN), TLS handshake, Request CERT (13):
  • TLSv1.2 (IN), TLS handshake, Server finished (14):
  • TLSv1.2 (OUT), TLS handshake, Certificate (11):
  • TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
  • TLSv1.2 (OUT), TLS handshake, CERT verify (15):
  • TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
  • TLSv1.2 (OUT), TLS handshake, Finished (20):
  • TLSv1.2 (IN), TLS change cipher, Change cipher spec (1):
  • TLSv1.2 (IN), TLS handshake, Finished (20):
  • SSL connection using TLSv1.2 / ECDHE-RSA-AES256-SHA384 ALPN, server did not agree to a protocol Server certificate: subject: CN=karaf@ start date: Jan 23 07:06:56 2020 GMT expire date: Jul 23 07:07:06 2020 GMT issuer: CN= SSL certificate verify result: self signed certificate in certificate chain (19), continuing anyway. GET /path/to/resource HTTP/1.1 Host: :13443 User-Agent: curl/7.65.0 Accept: / Mark bundle as not supporting multiuse < HTTP/1.1 200 OK < Date: Fri, 24 Jan 2020 10:53:03 GMT < Access-Control-Allow-Origin: * < Content-Type: application/json;charset=utf-8;profile=some-value# < X-Content-Type-Options: nosniff < X-Content-Type-Options: nosniff < Content-Length: 305 < Server: Jetty(9.3.21.v20170918) <

我的问题是服务器不同意哪种协议(protocol)?根据日志,似乎 ALPN 提出使用 http/1.1,但服务器可能不同意它,因此日志也不同意。

有什么解决办法吗?

为什么需要解决方案?

我认为,因此,在代码中调试时,最初作为 https 请求发送的请求解析为 http 请求。请参阅下面的日志。 enter image description here

最佳答案

事实证明jetty没有正确配置ssl。为了解决这个问题,我添加了以下配置。

<New id="tlsHttpConfig" class="org.eclipse.jetty.server.HttpConfiguration"> <Arg> <New id="httpConfig" class="org.eclipse.jetty.server.HttpConfiguration"> <!-- This says... Redirect to https://host:8443 if server returns "NOT SECURE" error --> <Set name="secureScheme">https</Set> <Set name="securePort">8443</Set> </New> </Arg> <Call name="addCustomizer"> <Arg> <New class="org.eclipse.jetty.server.SecureRequestCustomizer" /> </Arg> </Call> </New>

关于java - 为什么jetty服务器在发送请求时不同意协议(protocol)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59925444/

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