【问题标题】:Connection Failure when trying to make simple REST call to Jira API尝试对 Jira API 进行简单 REST 调用时连接失败
【发布时间】:2021-02-07 03:55:54
【问题描述】:

我有这个简单的 GET 调用,它可以在 Postman、Powershell、C# 甚至浏览器 JS 中完美运行(在禁用 CORS 之后),但是将其移植到 ColdFusion CFHTTP 调用失败。

以下是来自 Jira API 的响应:

{
  "ErrorDetail": "I/O Exception: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target",
  "Mimetype": "Unable to determine MIME type of file.",
  "Filecontent": "Connection Failure",
  "Statuscode": "Connection Failure.  Status code unavailable.",
  "Responseheader": {
    
  },
  "Text": true,
  "Charset": "",
  "Header": ""
}

CF 代码:

<cfset jql="<redacted>">
<cfset jiraEndpoint ='https://jira.bullhorn.com/rest/api/2/search?jql=#jql#'>

<cfhttp url = "#jiraEndpoint#" result="res" method="get" username="<redacted>" password="<redacted>">    
    <cfhttpparam type="header" name="Accept" value="application/json" />    
</cfhttp>

<cfheader name="Content-Type" value="application/json">
<cfoutput>
    #serializeJSON(res)#
</cfoutput>

我尝试过的事情:

  • 使用了值为"Basic &lt;base64 encoded string version of username:password&gt;" 的授权标头
  • 添加了Content-Type 标头
  • 添加了mimetype 标头
  • 尝试使用a third-party CFC

似乎没有任何效果。

【问题讨论】:

  • 这个错误听起来像是证书问题。例如hass.de/content/…
  • 我同意这是一个证书问题 - 虽然根据我的经验,除非端点服务器上存在“额外下载”错误配置,否则在 CF2016+ 和 Lucee 5+ 中不应该出现此问题,这在这种情况下没有,所以它看起来更像是由于使用 CF11,OP 不得不为 cfhttp 处理证书的结果。
  • @SevRoberts - 同意。刚刚才注意到CF11标签

标签: coldfusion jira-rest-api coldfusion-11


【解决方案1】:

Jira 的证书配置检查良好,包括他们的中间证书 - 您可以使用 ssllabs 或类似的测试人员确认这一点,例如 https://globalsign.ssllabs.com/analyze.html?d=jira.bullhorn.com

在您的情况下,您看到问题的原因是您使用的是旧版本的 Coldfusion,它使用的是旧 JVM,既不下载他们的 Digicert 中间证书,也没有预安装该证书。理想情况下,您应该从 CF11 升级。

对于一种解决方法,您可以手动将 Digicert 中间证书 + Jira Bullhorn 证书安装到服务器的 cacerts - 具体说明取决于您的环境,但一个示例是 https://helpx.adobe.com/coldfusion/kb/import-certificates-certificate-stores-coldfusion.html - 然后重新启动 CF 服务并重试 cfhttp 调用。

【讨论】:

    猜你喜欢
    • 2018-06-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-21
    • 1970-01-01
    • 1970-01-01
    • 2013-03-26
    相关资源
    最近更新 更多