首页 文章

Camel Http4使用基本身份验证和代理身份验证

提问于
浏览
0

我一直在尝试使用Apache Camel的Http4组件连接到需要基本身份验证的HTTPS URL . 连接需要通过经过身份验证的HTTP代理完成 .

所以,根据docs,我像这样配置Camel endpoints :

.toD("https4://target.host/resource?
        bridgeEndpoint=true
        &mapHttpMessageBody=false

        &proxyAuthHost=my.proxy.host
        &proxyAuthPort=myProxyPort
        &proxyAuthUsername=proxyUser
        &proxyAuthPassword=proxyPassword
        &proxyAuthScheme=http4

        &authenticationPreemptive=true
        &authUsername=myUser
        &authPassword=myPassword")

这导致目标服务器的 403 - Forbidden 响应 . 查看 org.apache.http.wire 日志,它显示代理凭证proxyUser / proxyPassword被转发到目标服务器,而不是 Authorization 标头中的预期myUser / myPassword .

调试CompositeHTTPConfigurer.configureHttpClientProxyHttpClientConfigurer.configureHttpClientBasicAuthenticationHttpClientConfigurer.configureHttpClient的源代码,似乎因为两个配置器都通过 setDefaultCredentialsProvider 将其凭据设置为 HttpClientBuilder ,其中一个丢失 - 被覆盖 - 在此过程中 .

看起来它可能是Camel的Http4组件中的一个错误?或者我错过了什么?

这是带有Spring Boot 1.5.1.RELEASE的Camel 2.18.2 .

1 回答

  • 1

    Apache Camel Users list上提出这个问题之后,似乎确认了这个错误 .

    我用 camel-http 而不是 camel-http4 解决了它 . endpoints 参数需要稍微调整:

    .toD("https://target.host/resource?
        bridgeEndpoint=true
    
        &proxyHost=my.proxy.host
        &proxyPort=myProxyPort
        &proxyAuthUsername=proxyUser
        &proxyAuthPassword=proxyPassword
        &proxyAuthMethod=Basic
    
        &authUsername=myUser
        &authPassword=myPassword
        &authMethod=Basic
        &httpClient.authenticationPreemptive=true")
    

相关问题