【发布时间】:2021-02-12 14:30:32
【问题描述】:
我们正在尝试设置一个桌面应用程序,该应用程序需要多因素身份验证登录才能连接到亚马逊的 API 网关。为此,我们使用 Amazon Cognito 进行身份验证,旨在将其与 API 网关集成。设置的 Cognito 和 API 网关部分都独立工作。问题在于添加安全性。
按照此处的文档:https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-integrate-with-cognito.html,我们已将 API 网关配置为使用授权方和令牌,通过 Cognito 成功登录时会收到该令牌。在AWS控制台测试授权方时,收到的token有效,认证通过。
尝试从桌面应用程序执行此操作时会出现此问题。经过数小时的文档和无休止的谷歌搜索后,我们仍然离让它工作更近了一步。
文档说我们必须使用“授权”键将令牌放在请求的标头中。我们这样做,但只是不断收到 HTTP 401(未经授权)。
正在发送的请求头如下(第一个黑色矩形是api端点,第二个是我们传入的token):
使用 postman 等 3rd 方应用时会看到相同的结果。
根据以下文档:https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-troubleshooting-jwt.html,我们尝试了 curl 命令:curl -v -H "Authorization: <token>" <endpoint>
但只是不断收到响应:
* Trying <ip>...
* TCP_NODELAY set
* Connected to <endpoint> port 443 (#0)
* schannel: SSL/TLS connection with <endpoint> port 443 (step 1/3)
* schannel: checking server certificate revocation
* schannel: sending initial handshake data: sending 217 bytes...
* schannel: sent initial handshake data: sent 217 bytes
* schannel: SSL/TLS connection with <endpoint> port 443 (step 2/3)
* schannel: failed to receive handshake, need more data
* schannel: SSL/TLS connection with <endpoint> port 443 (step 2/3)
* schannel: encrypted data got 4096
* schannel: encrypted data buffer: offset 4096 length 4096
* schannel: encrypted data length: 4030
* schannel: encrypted data buffer: offset 4030 length 4096
* schannel: received incomplete message, need more data
* schannel: SSL/TLS connection with <endpoint> port 443 (step 2/3)
* schannel: encrypted data got 1024
* schannel: encrypted data buffer: offset 5054 length 5054
* schannel: encrypted data length: 180
* schannel: encrypted data buffer: offset 180 length 5054
* schannel: received incomplete message, need more data
* schannel: SSL/TLS connection with <endpoint> port 443 (step 2/3)
* schannel: encrypted data got 167
* schannel: encrypted data buffer: offset 347 length 5054
* schannel: next InitializeSecurityContext failed: Unknown error (0x80092012) - The revocation function was unable to check revocation for the certificate.
* Closing connection 0
* schannel: shutting down SSL/TLS connection with <endpoint> port 443
* schannel: clear security context handle
curl: (35) schannel: next InitializeSecurityContext failed: Unknown error (0x80092012) - The revocation function was unable to check revocation for the certificate.
有人知道我们做错了什么吗?
在此先感谢
【问题讨论】:
标签: .net amazon-web-services api amazon-cognito gateway