- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
使用 spring boot Rest 模板调用 GET 调用时出现访问被拒绝错误的 sslhandshake 异常。
我正在开发一个 Java 客户端以从普罗米修斯服务器获取指标。创建一个带有基本身份验证的 RestTemplate 和带有 Tls1、1.1 和 1.2 的 sslContext。
但是在调用 GET 调用时出现以下异常。
org.springframework.web.client.ResourceAccessException: I/O error on GET request for "https://a5faff994509b11e99f7d0285e129587-2110882066.us-east-1.elb.amazonaws.com/api/v1/query": Received fatal alert: access_denied; nested exception is javax.net.ssl.SSLHandshakeException: Received fatal alert: access_denied
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:744)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:670)
at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:311)
at com.opscx.prometheus.PrometheusPocApplication.main(PrometheusPocApplication.java:40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
Caused by: javax.net.ssl.SSLHandshakeException: Received fatal alert: access_denied
at sun.security.ssl.Alerts.getSSLException(Unknown Source)
at sun.security.ssl.Alerts.getSSLException(Unknown Source)
at sun.security.ssl.SSLSocketImpl.recvAlert(Unknown Source)
at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:396)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:355)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:359)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:381)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:111)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
at org.springframework.http.client.HttpComponentsClientHttpRequest.executeInternal(HttpComponentsClientHttpRequest.java:87)
at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48)
at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:53)
at org.springframework.http.client.InterceptingClientHttpRequest$InterceptingRequestExecution.execute(InterceptingClientHttpRequest.java:108)
at com.opscx.prometheus.BasicAuthInterceptor.intercept(BasicAuthInterceptor.java:35)
at org.springframework.http.client.InterceptingClientHttpRequest$InterceptingRequestExecution.execute(InterceptingClientHttpRequest.java:92)
at org.springframework.http.client.InterceptingClientHttpRequest.executeInternal(InterceptingClientHttpRequest.java:76)
at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48)
at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:53)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:735)
... 11 more
类 org.springframework.web.client.ResourceAccessException
尝试使用 -Djavax.net.debug=ssl:handshake:verbose 进行调试,但无法找出问题所在。
这是调试日志的输出
trigger seeding of SecureRandom
done seeding SecureRandom
Allow unsafe renegotiation: false
Allow legacy hello messages: true
Is initial handshake: true
Is secure renegotiation: false
Ignoring unsupported cipher suite: TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 for TLSv1
Ignoring unsupported cipher suite: TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 for TLSv1
Ignoring unsupported cipher suite: TLS_RSA_WITH_AES_256_CBC_SHA256 for TLSv1
Ignoring unsupported cipher suite: TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384 for TLSv1
Ignoring unsupported cipher suite: TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384 for TLSv1
Ignoring unsupported cipher suite: TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 for TLSv1
Ignoring unsupported cipher suite: TLS_DHE_DSS_WITH_AES_256_CBC_SHA256 for TLSv1
Ignoring unsupported cipher suite: TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 for TLSv1.1
Ignoring unsupported cipher suite: TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 for TLSv1.1
Ignoring unsupported cipher suite: TLS_RSA_WITH_AES_256_CBC_SHA256 for TLSv1.1
Ignoring unsupported cipher suite: TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384 for TLSv1.1
Ignoring unsupported cipher suite: TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384 for TLSv1.1
Ignoring unsupported cipher suite: TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 for TLSv1.1
Ignoring unsupported cipher suite: TLS_DHE_DSS_WITH_AES_256_CBC_SHA256 for TLSv1.1
%% No cached client session
*** ClientHello, TLSv1.2
RandomCookie: GMT: 1542173365 bytes = { 177, 65, 144, 227, 154, 51, 246, 129, 182, 251, 188, 204, 134, 212, 156, 222, 208, 90, 86, 46, 87, 105, 16, 134, 146, 83, 144, 225 }
Session ID: {}
Cipher Suites: [TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384, TLS_RSA_WITH_AES_256_CBC_SHA256, TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384, TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384, TLS_DHE_RSA_WITH_AES_256_CBC_SHA256, TLS_DHE_DSS_WITH_AES_256_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDH_RSA_WITH_AES_256_CBC_SHA, TLS_DHE_RSA_WITH_AES_256_CBC_SHA, TLS_DHE_DSS_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_DSS_WITH_AES_128_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, TLS_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384, TLS_DHE_RSA_WITH_AES_256_GCM_SHA384, TLS_DHE_DSS_WITH_AES_256_GCM_SHA384, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_DSS_WITH_AES_128_GCM_SHA256, TLS_EMPTY_RENEGOTIATION_INFO_SCSV]
Compression Methods: { 0 }
Extension elliptic_curves, curve names: {secp256r1, secp384r1, secp521r1, sect283k1, sect283r1, sect409k1, sect409r1, sect571k1, sect571r1, secp256k1}
Extension ec_point_formats, formats: [uncompressed]
Extension signature_algorithms, signature_algorithms: SHA512withECDSA, SHA512withRSA, SHA384withECDSA, SHA384withRSA, SHA256withECDSA, SHA256withRSA, SHA256withDSA, SHA1withECDSA, SHA1withRSA, SHA1withDSA
Extension extended_master_secret
Extension server_name, server_name: [type=host_name (0), value=a5faff994509b11e99f7d0285e129587-2110882066.us-east-1.elb.amazonaws.com]
***
main, WRITE: TLSv1.2 Handshake, length = 273
main, READ: TLSv1 Alert, length = 2
main, RECV TLSv1.2 ALERT: fatal, access_denied
main, called closeSocket()
main, handling exception: javax.net.ssl.SSLHandshakeException: Received fatal alert: access_denied
这是我的代码
SSLContext sslContext = null;
try {
sslContext = SSLContextBuilder.create()
.loadTrustMaterial(null, (chain, authType) -> true)
.build();
} catch (KeyManagementException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (KeyStoreException e) {
e.printStackTrace();
}
SSLConnectionSocketFactory sslConnectionSocketFactory =
new SSLConnectionSocketFactory(sslContext,
new String[] { "TLSv1","TLSv1.1","TLSv1.2" },
//null,
null,
new LaxHostnameVerifier());
PoolingHttpClientConnectionManager poolingHttpClientConnectionManager =
new PoolingHttpClientConnectionManager(RegistryBuilder.<ConnectionSocketFactory> create()
.register("http",
PlainConnectionSocketFactory.getSocketFactory())
.register("https",
sslConnectionSocketFactory)
.build());
CloseableHttpClient httpClient = HttpClientBuilder.create().setConnectionManager(poolingHttpClientConnectionManager).build();
return httpClient;
我正在创建一个包含所有三个 TLS 协议(protocol)的 sslcontext。调试日志的输出让我感到困惑。
main, WRITE: TLSv1.2 Handshake, length = 273
main, READ: TLSv1 Alert, length = 2
main, RECV TLSv1.2 ALERT: fatal, access_denied
clienthello 是用 TLSV1.2 完成的,为什么会有一个 TLSv1 警报的 READ 消息?然后奇怪的是 TLSv1.2 ALERT 的 RECV 消息?
如果服务器能够使用 TLSv1.2 发送警报,为什么它不接受握手请求?
所有密码套件都已启用,它应该同意任何一个密码。双方都有共同的密码。
相同的代码适用于其他基于 REST 的服务器。我通常不会随调用发送证书,它应该可以工作。
注意:IST 昨晚使用了相同的代码。奇怪的是有时能用有时不能用
我在这上面花了更多的时间,但无法获得访问被拒绝错误的足够答案。如果有人能给我一些这方面的见解,那就太好了。
最佳答案
The clienthello is done with TLSV1.2, why is there a READ message of a TLSv1 alert ? and then strangely a RECV message of TLSv1.2 ALERT ?
服务器决定它不喜欢这个客户端。来自 TLS alwert 的描述:
access_denied
A valid certificate was received, but when access control wasapplied, the sender decided not to proceed with negotiation. Thismessage is always fatal.
因此,您需要与服务器提供商核实服务器对客户端的实际要求是什么。例如,客户端可能需要提供特定的客户端证书,而您没有提供或提供了错误的证书。
关于java - SSL 握手异常 : Received fatal alert: access_denied,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56334936/
通过使用以下curl命令,我可以访问 token 并获得以下响应curl 用户名:密码@机器名:11002/appName/oauth/token -d grant_type=密码 -d 用户名=lo
我目前将应用程序转换为使用 CreateProcessW() 而不是 Runtime.exec(),因为我需要它提供的信息。但是,对 CreateProcessW() 的任何调用都会失败,并显示错误代
我目前使用 sphinxql 并在我的 $query 上使用 mysql_real_escape_string 但由于没有数据库连接...我的访问被拒绝。我在寻找替代品: $query = $_GET
我有一个 java vertx 服务器和一个 JavaScript 客户端。我想在两次下创建一个事件总线,但 vertx 响应:连接时收到错误:access_denied Javascript 代码:
我正在我的 asp.net webapi 2 中实现 oAuth 流。我必须获得用户的许可才能访问他们的 google 分析数据。为此,我在向 google oAuth2.0 流程发送身份验证请求时添
此程序枚举所有句柄并获取它们的名称。 对于 pID 4,OpenProcess 使用 SeDebugPrivilege 获得错误 5。 UAC 关闭。从管理员运行。 启用 SeDebugPrivile
我使用 rails 5.0 康康 1.6.10 设计 4.2.0 事件管理员 我经常在 newrelic 中遇到此错误: NoMethodError: undefined method `access
我正在尝试使用 Java Google Calendar api 连接到日历。 java 应用程序使用服务帐户。 我有以下代码: java.io.File licenseFile = new j
我正在尝试将 google drive photo 下载到我的本地驱动器。我认为这应该是一项简单的任务,但它实际上具有挑战性,尤其是这是我第一次尝试使用 google API。 按照这个有用的 You
我按照下面的这篇文章进行操作,但在“测试用户流程”部分中收到了以下错误: https://learn.microsoft.com/en-gb/azure/active-directory-b2c/co
我按照下面的这篇文章进行操作,但在“测试用户流程”部分中收到了以下错误: https://learn.microsoft.com/en-gb/azure/active-directory-b2c/co
我正在尝试对 WebApi 实现 OAuth 身份验证,我已经使用以下方法创建了 Controller (直接来自示例): [OverrideAuthentication] [Host
使用 spring boot Rest 模板调用 GET 调用时出现访问被拒绝错误的 sslhandshake 异常。 我正在开发一个 Java 客户端以从普罗米修斯服务器获取指标。创建一个带有基本身
我想使用服务帐户访问谷歌日历。这是我的代码: 被 Google API 控制台上的正确值所取代。 .apps.googleusercontent.com'; const SERVICE_ACCOUNT
我已经设置了我的 Google OAuth 我已将代码添加到 Startup.Auth.cs app.UseGoogleAuthentication(new GoogleOAuth2Authenti
我是 Playframework 的新手。我的intellij无法导入sbt项目,因此尝试直接运行sbt。 在空文件夹中运行:sbt 并获取: Getting org.scala-sbt sbt 1.
我的网站上的 Facebook 登录遇到了一个奇怪的问题。这是全新的东西,Facebook 登录始终正常工作,并且仍在我的 Android 和 iOS 应用程序上工作。 我在网站上有一个链接,例如:
我正在尝试从其 pid 获取进程名称。用户以管理员身份运行,UAC 已启用,但未提升。 某些系统进程(例如 services.exe)的安全设置导致 OpenProcess(PROCESS_QUERY
我目前已经走进了 OAuth2 的世界,并对它有了一些的了解。我正在尝试制作一个应用程序,您可以在其中授权 Discord 帐户并让它自动邀请您加入公会/服务器。 我正在 Nginx 代理后面使用 E
我正在尝试从其 pid 中获取进程名称。用户以管理员身份运行,启用 UAC,但未提升权限。 一些系统进程,如 services.exe,以这样的方式设置它们的安全性 OpenProcess(PROCE
我是一名优秀的程序员,十分优秀!