spring-cloud-gateway icon indicating copy to clipboard operation
spring-cloud-gateway copied to clipboard

Self Signed SSL backend

Open runabol opened this issue 8 years ago • 7 comments

Is there a way to pass in a certificate file (similar to --cacert on curl) to validate a self-signed backend?

runabol avatar Dec 18 '17 18:12 runabol

Not currently. You could probably do it creating a bean like so

		@Bean
		public Consumer<? super HttpClientOptions.Builder> nettyClientOptions() {
			return opts -> {
				opts.poolResources(PoolResources.elastic("proxy"));
				// opts.disablePool(); //TODO: why do I need this again?
			};
		}

And setting the appropriate options on the netty http client.

spencergibb avatar Dec 18 '17 19:12 spencergibb

Attempted this with little success.

         @Bean
	public Consumer<? super HttpClientOptions.Builder> nettyClientOptions() {
		return opts -> {
			opts.poolResources(PoolResources.elastic("proxy"));
			SslContextBuilder builder = SslContextBuilder.forClient();
			builder.clientAuth(ClientAuth.NONE);
			builder.trustManager(InsecureTrustManagerFactory.INSTANCE);
			try {
				opts.sslContext(builder.build());
			} catch (SSLException e) {
				e.printStackTrace();
			}
		};
	}

saiyedzaidi avatar Jan 23 '18 10:01 saiyedzaidi

Yeah, you may have to actually override the HttpClient bean.

spencergibb avatar Jan 30 '18 00:01 spencergibb

The snippet worked with 2.0 snapshot now, since the fix for URL rewrite SSL issue is there.

saiyedzaidi avatar Feb 01 '18 04:02 saiyedzaidi

@spencergibb should the code that creates the http client be moved up to sc-commons? Similar to what we did with the apache and OK http clients?

ryanjbaxter avatar Feb 01 '18 14:02 ryanjbaxter

No, I don't think so. Nothing else uses a netty HttpClient.

spencergibb avatar Feb 02 '18 18:02 spencergibb

Closed via a2ca131b50a2a35308fe5274b1120ef9fe216d4b

spencergibb avatar Mar 01 '18 21:03 spencergibb