Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id A2967200B61 for ; Mon, 25 Jul 2016 15:14:22 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id A1306160A78; Mon, 25 Jul 2016 13:14:22 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id A7CA7160A91 for ; Mon, 25 Jul 2016 15:14:21 +0200 (CEST) Received: (qmail 35742 invoked by uid 500); 25 Jul 2016 13:14:20 -0000 Mailing-List: contact dev-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpComponents Project" Delivered-To: mailing list dev@hc.apache.org Received: (qmail 35578 invoked by uid 99); 25 Jul 2016 13:14:20 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 25 Jul 2016 13:14:20 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 9B9F92C0D60 for ; Mon, 25 Jul 2016 13:14:20 +0000 (UTC) Date: Mon, 25 Jul 2016 13:14:20 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: dev@hc.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (HTTPCLIENT-1752) Allow to configure the OSGI clients with relaxed SSL checks MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Mon, 25 Jul 2016 13:14:22 -0000 [ https://issues.apache.org/jira/browse/HTTPCLIENT-1752?page=3Dcom.atla= ssian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId= =3D15391860#comment-15391860 ]=20 ASF GitHub Bot commented on HTTPCLIENT-1752: -------------------------------------------- Github user simonetripodi commented on a diff in the pull request: https://github.com/apache/httpclient/pull/56#discussion_r72060532 =20 --- Diff: httpclient5-osgi/src/main/java/org/apache/hc/client5/http/osg= i/impl/RelaxedLayeredConnectionSocketFactory.java --- @@ -0,0 +1,101 @@ +/* + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + * + */ +package org.apache.hc.client5.http.osgi.impl; + +import static org.apache.hc.client5.http.osgi.impl.HostMatcher.HostMat= cherFactory.createMatcher; +import static org.apache.hc.client5.http.ssl.SSLConnectionSocketFactor= y.getSocketFactory; + +import java.io.IOException; +import java.net.InetSocketAddress; +import java.net.Socket; + +import org.apache.hc.client5.http.osgi.services.TrustedHostsConfigurat= ion; +import org.apache.hc.client5.http.socket.LayeredConnectionSocketFactor= y; +import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory; +import org.apache.hc.core5.http.HttpHost; +import org.apache.hc.core5.http.protocol.HttpContext; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceRegistration; + +final class RelaxedLayeredConnectionSocketFactory implements LayeredCo= nnectionSocketFactory { + + private final SSLConnectionSocketFactory defaultSocketFactory =3D = getSocketFactory(); --- End diff -- =20 @ok2c I just implemented the required behaviour in my last commit, test= s are up and running - any feedback would be more than appreciated, thanks = in advance! > Allow to configure the OSGI clients with relaxed SSL checks > ----------------------------------------------------------- > > Key: HTTPCLIENT-1752 > URL: https://issues.apache.org/jira/browse/HTTPCLIENT-175= 2 > Project: HttpComponents HttpClient > Issue Type: New Feature > Components: HttpClient > Affects Versions: 4.5.2 > Reporter: Timothee Maret > Assignee: Simone Tripodi > Fix For: Future > > Attachments: HTTPCLIENT-1752_initial.patch > > > In deployments other than production (e.g. dev, qa, integration testing, = etc.) it is often useful to deploy self-signed certificates instead of cert= ificates signed by a trusted CA for cost and simplicity reasons. > By default, the http client does not validate a self signed certificate b= ecause it is not signed by a trusted CA root.=20 > One way to have the http client to validate the self signed certificate i= s to add the self-signed certificate (or the detached CA root that signed i= t) in the java trustore. > This operation is a configuration only change (no need to change code) ho= wever it typically requires accessing the FS and the scope of trust can't b= e easily modified at runtime. > Another way to have the http client to validate the self signed certifica= te is to use the TrustSelfSignedStrategy [0] strategy when building the htt= p client. > This requires modifying the code. > In order to use the second approach without modifying code, it would be i= nteresting to allow configuring a set of URIs for which the relaxed SSL mod= e should be used. > The configuration could be implemented similarly to the implementation of= the central prox configuration (OSGI) in HTTPCLIENT-1238. In addition to a= llowing sel-signed certificates, the configuration could as well allow to s= kip FQDN check using the NoopHostnameVerifier [1]. > Of course, this feature *must not* be deployed in production environment = as it is totally insecure. > [0]=C2=A0https://hc.apache.org/httpcomponents-client-ga/httpclient/apidoc= s/org/apache/http/conn/ssl/TrustSelfSignedStrategy.html > [1] https://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org= /apache/http/conn/ssl/NoopHostnameVerifier.html -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org For additional commands, e-mail: dev-help@hc.apache.org