【问题标题】:Camel Http4 using basic auth and proxy authCamel Http4 使用基本身份验证和代理身份验证
【发布时间】:2017-03-06 15:54:01
【问题描述】:

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

所以,根据docs,我这样配置Camel端点:

.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 被转发到目标服务器,而不是预期的 myUser/ myPasswordAuthorization 标头中。

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

看起来这可能是 Camel 的 Http4 组件中的错误?还是我错过了什么?

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

【问题讨论】:

    标签: java apache-camel proxy-authentication camel-http


    【解决方案1】:

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

    我使用camel-http 而不是camel-http4 解决了这个问题。端点参数需要稍作调整:

    .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")
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-10-10
      • 2011-01-28
      • 1970-01-01
      • 2017-03-10
      • 2018-07-19
      • 2014-09-15
      • 2011-03-22
      • 2021-06-20
      相关资源
      最近更新 更多