Zuul: https protocol is not supported - when trying to access any endpoints through zuul gateway
I have an issue with Zuul when trying to route to https secured resources. I'm using 2.0.0.M3 for Spring Boot with embedded Jetty and 2.0.0.M2 for spring cloud.
Zuul, Eureka (peers) and Eureka Clients are all CA Cert signed by a local certificate authority and work as expected individually(the secure icon is visible in firefox for zuul, eureka and the client)

The problem occurs when I try to access the client endpoint or Eureka endpoint through the zuul https 9443 port.
I get the following error: (see abbreviated ERROR below)
The services are located and pinged via https correctly (see SAMPLE JOB LOG below):
Configuration files shown below are (ZUUL, EUREKA SERVER and DISCOVERABLE CLIENT) The fetch/interval reduction is deliberate for local testing. As discoverable clients can register themselves dynamically and without requiring modification of zuul, I do not want to have to use static routes in Zuul, hence the lack of them.
I've tried the workaround whereby you do not use root or an empty URI for the endpoint but that doesn't work. it hits and correctly enters the "updateToHttpsIfNeeded" method.
I do not have any custom filters or Jetty overrides in the zuul application, eureka service or client service.
ZUUL
server:
port: 9443
ssl:
enabled: true
key-store: classpath:ssl/server_keystore.jks
key-store-password: password
key-password: password
trust-store: classpath:ssl/server_truststore.jks
trust-store-password: password
eureka:
instance:
preferIpAddress: false
leaseRenewalIntervalInSeconds: 5
leaseExpirationDurationInSeconds: 5
nonSecurePortEnabled: false
securePortEnabled: true
securePort: 9443
statusPageUrl: https://apigateway:9443/info
healthCheckUrl: https://apigateway:9443/health
homePageUrl: https://apigateway:9443/
client:
fetchRegistry: true
registerWithEureka: true
region: default
serviceUrl:
defaultZone: https://peer1:9000/eureka/,https://peer2:9001/eureka/
healthcheck:
enabled: true
ribbon:
IsSecure: true
spring:
application:
name: gateway
environment:
hostName: apigateway
security:
basic:
enabled: false
zuul:
trace-request-body: true
EUREKA SERVER
ribbon:
IsSecure: true
management:
security:
enabled: false
eureka:
instance:
leaseRenewalIntervalInSeconds: 5
leaseExpirationDurationInSeconds: 5
---
spring:
profiles: peer1
environment:
hostName: peer1
server:
port: ${environment.port:9000}
ssl:
enabled: true
key-store: classpath:ssl/client_peer1_keystore.jks
key-store-password: password
key-password: password
trust-store: classpath:ssl/server_truststore.jks
trust-store-password: password
eureka:
instance:
hostname: peer1
nonSecurePortEnabled: false
securePortEnabled: true
securePort: 9000
statusPageUrl: https://peer1:9000/info
healthCheckUrl: https://peer1:9000/health
homePageUrl: https://peer1:9000/
server:
waitTimeInMsWhenSyncEmpty: 0
enable-self-preservation: false
client:
enabled: true
fetch-registry: true
register-with-eureka: true
registryFetchIntervalSeconds: 5
initialInstanceInfoReplicationIntervalSeconds: 5
serviceUrl:
defaultZone: https://peer1:9000/eureka/,https://peer2:9001/eureka/
---
spring:
profiles: peer2
environment:
hostName: peer2
server:
port: ${environment.port:9001}
ssl:
enabled: true
key-store: classpath:ssl/client_peer2_keystore.jks
key-store-password: password
key-password: password
trust-store: classpath:ssl/server_truststore.jks
trust-store-password: password
eureka:
instance:
hostname: peer2
nonSecurePortEnabled: false
securePortEnabled: true
securePort: 9001
statusPageUrl: https://peer2:9001/info
healthCheckUrl: https://peer2:9001/health
homePageUrl: https://peer2:9001/
server:
waitTimeInMsWhenSyncEmpty: 0
enable-self-preservation: false
client:
enabled: true
fetch-registry: true
register-with-eureka: true
registryFetchIntervalSeconds: 5
initialInstanceInfoReplicationIntervalSeconds: 5
serviceUrl:
defaultZone: https://peer1:9000/eureka/,https://peer2:9001/eureka/
DISCOVERABLE CLIENT
server:
port: ${environment.port:12345}
ssl:
enabled: true
key-store: classpath:ssl/client_keystore.jks
key-store-password: password
key-password: password
trust-store: classpath:ssl/server_truststore.jks
trust-store-password: password
spring:
application:
name: ${environment.name:discoverable-client}
eureka:
instance:
nonSecurePortEnabled: false
securePortEnabled: true
securePort: 12345
leaseExpirationDurationInSeconds: 5
leaseRenewalIntervalInSeconds: 5
statusPageUrl: https://client:12345/info
healthCheckUrl: hhttps://client:12345/health
homePageUrl: https://client:12345/
client:
registryFetchIntervalSeconds: 5
initialInstanceInfoReplicationIntervalSeconds: 5
serviceUrl:
defaultZone: https://peer1:9000/eureka/,https://peer2:9001/eureka/
healthcheck:
enabled: true
environment:
hostName: client
management:
security:
enabled: false
security:
basic:
enabled: false
CLIENT FEIGN/RIBBON CONFIG
moviecontroller-client:
ribbon:
DeploymentContextBasedVipAddresses: ${environment.name:discoverable-client}
NIWSServerListClassName: com.netflix.niws.loadbalancer.DiscoveryEnabledNIWSServerList
ReadTimeout: 5000
MaxAutoRetries: 2
suspectscontroller-client:
ribbon:
DeploymentContextBasedVipAddresses: ${environment.name:discoverable-client}
NIWSServerListClassName: com.netflix.niws.loadbalancer.DiscoveryEnabledNIWSServerList
ReadTimeout: 5000
MaxAutoRetries: 2
SAMPLE JOB LOG
017-10-17 14:23:59.169 DEBUG 7118 --- [tbeatExecutor-0] c.n.d.shared.MonitoredConnectionManager : Get connection: {s}->https://peer1:9000, timeout = 5000
2017-10-17 14:23:59.169 DEBUG 7118 --- [tbeatExecutor-0] c.n.d.shared.NamedConnectionPool : [{s}->https://peer1:9000] total kept alive: 1, total issued: 0, total allocated: 1 out of 200
2017-10-17 14:23:59.169 DEBUG 7118 --- [tbeatExecutor-0] c.n.d.shared.NamedConnectionPool : Getting free connection [{s}->https://peer1:9000][null]
2017-10-17 14:23:59.173 DEBUG 7118 --- [tbeatExecutor-0] c.n.d.shared.MonitoredConnectionManager : Released connection is reusable.
2017-10-17 14:23:59.173 DEBUG 7118 --- [tbeatExecutor-0] c.n.d.shared.NamedConnectionPool : Releasing connection [{s}->https://peer1:9000][null]
2017-10-17 14:23:59.173 DEBUG 7118 --- [tbeatExecutor-0] c.n.d.shared.NamedConnectionPool : Pooling connection [{s}->https://peer1:9000][null]; keep alive indefinitely
2017-10-17 14:23:59.173 DEBUG 7118 --- [tbeatExecutor-0] c.n.d.shared.NamedConnectionPool : Notifying no-one, there are no waiting threads
2017-10-17 14:23:59.173 DEBUG 7118 --- [tbeatExecutor-0] n.d.s.t.j.AbstractJerseyEurekaHttpClient : Jersey HTTP PUT https://peer1:9000/eureka//apps/GATEWAY/192.168.0.242:gateway:9443; statusCode=200
2017-10-17 14:23:59.173 DEBUG 7118 --- [tbeatExecutor-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_GATEWAY/192.168.0.242:gateway:9443 - Heartbeat status: 200
2017-10-17 14:24:04.173 DEBUG 7118 --- [tbeatExecutor-0] c.n.d.shared.MonitoredConnectionManager : Get connection: {s}->https://peer1:9000, timeout = 5000
2017-10-17 14:24:04.173 DEBUG 7118 --- [tbeatExecutor-0] c.n.d.shared.NamedConnectionPool : [{s}->https://peer1:9000] total kept alive: 1, total issued: 0, total allocated: 1 out of 200
2017-10-17 14:24:04.173 DEBUG 7118 --- [tbeatExecutor-0] c.n.d.shared.NamedConnectionPool : Getting free connection [{s}->https://peer1:9000][null]
2017-10-17 14:24:04.176 DEBUG 7118 --- [tbeatExecutor-0] c.n.d.shared.MonitoredConnectionManager : Released connection is reusable.
2017-10-17 14:24:04.176 DEBUG 7118 --- [tbeatExecutor-0] c.n.d.shared.NamedConnectionPool : Releasing connection [{s}->https://peer1:9000][null]
2017-10-17 14:24:04.176 DEBUG 7118 --- [tbeatExecutor-0] c.n.d.shared.NamedConnectionPool : Pooling connection [{s}->https://peer1:9000][null]; keep alive indefinitely
2017-10-17 14:24:04.176 DEBUG 7118 --- [tbeatExecutor-0] c.n.d.shared.NamedConnectionPool : Notifying no-one, there are no waiting threads
2017-10-17 14:24:04.176 DEBUG 7118 --- [tbeatExecutor-0] n.d.s.t.j.AbstractJerseyEurekaHttpClient : Jersey HTTP PUT https://peer1:9000/eureka//apps/GATEWAY/192.168.0.242:gateway:9443; statusCode=200
2017-10-17 14:24:04.176 DEBUG 7118 --- [tbeatExecutor-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_GATEWAY/192.168.0.242:gateway:9443 - Heartbeat status: 200
2017-10-17 14:24:08.463 DEBUG 7118 --- [overable-client] c.netflix.loadbalancer.BaseLoadBalancer : LoadBalancer: PingTask executing [1] servers configured
2017-10-17 14:24:09.176 DEBUG 7118 --- [tbeatExecutor-0] c.n.d.shared.MonitoredConnectionManager : Get connection: {s}->https://peer1:9000, timeout = 5000
2017-10-17 14:24:09.177 DEBUG 7118 --- [tbeatExecutor-0] c.n.d.shared.NamedConnectionPool : [{s}->https://peer1:9000] total kept alive: 1, total issued: 0, total allocated: 1 out of 200
2017-10-17 14:24:09.177 DEBUG 7118 --- [tbeatExecutor-0] c.n.d.shared.NamedConnectionPool : Getting free connection [{s}->https://peer1:9000][null]
2017-10-17 14:24:09.180 DEBUG 7118 --- [tbeatExecutor-0] c.n.d.shared.MonitoredConnectionManager : Released connection is reusable.
2017-10-17 14:24:09.180 DEBUG 7118 --- [tbeatExecutor-0] c.n.d.shared.NamedConnectionPool : Releasing connection [{s}->https://peer1:9000][null]
2017-10-17 14:24:09.180 DEBUG 7118 --- [tbeatExecutor-0] c.n.d.shared.NamedConnectionPool : Pooling connection [{s}->https://peer1:9000][null]; keep alive indefinitely
2017-10-17 14:24:09.180 DEBUG 7118 --- [tbeatExecutor-0] c.n.d.shared.NamedConnectionPool : Notifying no-one, there are no waiting threads
2017-10-17 14:24:09.180 DEBUG 7118 --- [tbeatExecutor-0] n.d.s.t.j.AbstractJerseyEurekaHttpClient : Jersey HTTP PUT https://peer1:9000/eureka//apps/GATEWAY/192.168.0.242:gateway:9443; statusCode=200
2017-10-17 14:24:09.180 DEBUG 7118 --- [tbeatExecutor-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_GATEWAY/192.168.0.242:gateway:9443 - Heartbeat status: 200
LOG AFTER ERROR
2017-10-17 15:07:21.979 INFO 7118 --- [tp1233246555-20] o.apache.http.impl.execchain.RetryExec : I/O exception (org.apache.http.conn.UnsupportedSchemeException) caught when processing request to {s}->https://peer2:9001: https protocol is not supported
2017-10-17 15:07:21.979 INFO 7118 --- [tp1233246555-20] o.apache.http.impl.execchain.RetryExec : Retrying request to {s}->https://peer2:9001
2017-10-17 15:07:21.979 INFO 7118 --- [tp1233246555-20] o.apache.http.impl.execchain.RetryExec : I/O exception (org.apache.http.conn.UnsupportedSchemeException) caught when processing request to {s}->https://peer2:9001: https protocol is not supported
2017-10-17 15:07:21.979 INFO 7118 --- [tp1233246555-20] o.apache.http.impl.execchain.RetryExec : Retrying request to {s}->https://peer2:9001
2017-10-17 15:07:21.979 INFO 7118 --- [tp1233246555-20] o.apache.http.impl.execchain.RetryExec : I/O exception (org.apache.http.conn.UnsupportedSchemeException) caught when processing request to {s}->https://peer2:9001: https protocol is not supported
2017-10-17 15:07:21.979 INFO 7118 --- [tp1233246555-20] o.apache.http.impl.execchain.RetryExec : Retrying request to {s}->https://peer2:9001
2017-10-17 15:07:21.979 DEBUG 7118 --- [tp1233246555-20] c.n.l.reactive.LoadBalancerCommand : Got error org.apache.http.conn.UnsupportedSchemeException: https protocol is not supported when executed on server peer2:9001
2017-10-17 15:07:21.982 DEBUG 7118 --- [tp1233246555-20] com.netflix.hystrix.AbstractCommand : Error executing HystrixCommand.run(). Proceeding to fallback logic ...
ERROR (abbreviated)
com.netflix.zuul.exception.ZuulException: Forwarding error
at org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter.handleException(RibbonRoutingFilter.java:188)
at org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter.forward(RibbonRoutingFilter.java:163)
at org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter.run(RibbonRoutingFilter.java:111)
at com.netflix.zuul.ZuulFilter.runFilter(ZuulFilter.java:112)
at com.netflix.zuul.FilterProcessor.processZuulFilter(FilterProcessor.java:193)
at com.netflix.zuul.FilterProcessor.runFilters(FilterProcessor.java:157)
at com.netflix.zuul.FilterProcessor.route(FilterProcessor.java:118)
at com.netflix.zuul.ZuulRunner.route(ZuulRunner.java:96)
at com.netflix.zuul.http.ZuulServlet.route(ZuulServlet.java:116)
at com.netflix.zuul.http.ZuulServlet.service(ZuulServlet.java:81)
at org.springframework.web.servlet.mvc.ServletWrappingController.handleRequestInternal(ServletWrappingController.java:165)
at org.springframework.cloud.netflix.zuul.web.ZuulController.handleRequest(ZuulController.java:44)
at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:50)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:981)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:915)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:978)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:870)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:855)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:841)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1650)
at org.springframework.boot.actuate.trace.WebRequestTraceFilter.doFilterInternal(WebRequestTraceFilter.java:110)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1637)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:208)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:177)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:357)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:270)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1637)
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
...
com.netflix.client.ClientException: null
at com.netflix.client.AbstractLoadBalancerAwareClient.executeWithLoadBalancer(AbstractLoadBalancerAwareClient.java:123) ~[ribbon-loadbalancer-2.2.2.jar:2.2.2]
at org.springframework.cloud.netflix.zuul.filters.route.support.AbstractRibbonCommand.run(AbstractRibbonCommand.java:108) ~[spring-cloud-netflix-core-2.0.0.M2.jar:2.0.0.M2]
at org.springframework.cloud.netflix.zuul.filters.route.support.AbstractRibbonCommand.run(AbstractRibbonCommand.java:44) ~[spring-cloud-netflix-core-2.0.0.M2.jar:2.0.0.M2]
at com.netflix.hystrix.HystrixCommand$2.call(HystrixCommand.java:302) ~[hystrix-core-1.5.12.jar:1.5.12]
at com.netflix.hystrix.HystrixCommand$2.call(HystrixCommand.java:298) ~[hystrix-core-1.5.12.jar:1.5.12]
at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:46) [rxjava-1.3.0.jar:1.3.0
....
Caused by: java.lang.RuntimeException: org.apache.http.conn.UnsupportedSchemeException: https protocol is not supported
at rx.exceptions.Exceptions.propagate(Exceptions.java:57) ~[rxjava-1.3.0.jar:1.3.0]
at rx.observables.BlockingObservable.blockForSingle(BlockingObservable.java:463) [rxjava-1.3.0.jar:1.3.0]
at rx.observables.BlockingObservable.single(BlockingObservable.java:340) [rxjava-1.3.0.jar:1.3.0]
at com.netflix.client.AbstractLoadBalancerAwareClient.executeWithLoadBalancer(AbstractLoadBalancerAwareClient.java:117) ~[ribbon-loadbalancer-2.2.2.jar:2.2.2]
... 136 common frames omitted
Caused by: org.apache.http.conn.UnsupportedSchemeException: https protocol is not supported
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:109) ~[httpclient-4.5.3.jar:4.5.3]
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:359) ~[httpclient-4.5.3.jar:4.5.3]
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:381) ~[httpclient-4.5.3.jar:4.5.3]
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237) ~[httpclient-4.5.3.jar:4.5.3]
]
.....
java.lang.UnsupportedOperationException: No fallback available.
at com.netflix.hystrix.HystrixCommand.getFallback(HystrixCommand.java:293) [hystrix-core-1.5.12.jar:1.5.12]
at org.springframework.cloud.netflix.zuul.filters.route.support.AbstractRibbonCommand.getFallback(AbstractRibbonCommand.java:129) ~[spring-cloud-netflix-core-2.0.0.M2.jar:2.0.0.M2]
at org.springframework.cloud.netflix.zuul.filters.route.support.AbstractRibbonCommand.getFallback(AbstractRibbonCommand.java:44) ~[spring-cloud-netflix-core-2.0.0.M2.jar:2.0.0.M2]
at com.netflix.hystrix.HystrixCommand$3.call(HystrixCommand.java:322) ~[hystrix-core-1.5.12.jar:1.5.12]
at com.netflix.hystrix.HystrixCommand$3.call(HystrixCommand.java:318) ~[hystrix-core-1.5.12.jar:1.5.12]
at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:46) [rxjava-1.3.0.jar:1.3.0]
at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:35) [rxjava-1.3.0.jar:1.3.0]
Looks like this SO post might be helpful https://stackoverflow.com/questions/36268092/how-to-use-httpclientbuilder-with-http-proxy
I notice this happening with the Edgware.RELEASE. When I roll back to Dalston.SR4 the issue is not present.
@spencergibb I Ran into this as well, Had to supply an implementation of RegistryBuilder to make this work. I am on Edgware.RELEASE
@Bean
public RegistryBuilder registryBuilder() {
return RegistryBuilder.<ConnectionSocketFactory> create()
.register(HTTP_SCHEME, PlainConnectionSocketFactory.INSTANCE)
.register(HTTPS_SCHEME, SSLConnectionSocketFactory.getSocketFactory());
}
I think the problem is here https://github.com/spring-cloud/spring-cloud-commons/blob/master/spring-cloud-commons/src/main/java/org/springframework/cloud/commons/httpclient/DefaultApacheHttpClientConnectionManagerFactory.java#L64
We should probably add SSLConnectionSocketFactory unless disabled.
@winash @dmfrey agree?
@ryanjbaxter +1 The else case is missing in 1.3.0-Release.
Yeah so it will be fixed in the next Edgware release then.
Ran into this as well with Edgware.RELEASE Had to add
@Bean
public ApacheHttpClientConnectionManagerFactory connManFactory () {
return new DefaultApacheHttpClientConnectionManagerFactory () {
@Override
public HttpClientConnectionManager newConnectionManager ( boolean disableSslValidation, int maxTotalConnections, int maxConnectionsPerRoute,
long timeToLive, TimeUnit timeUnit, RegistryBuilder registryBuilder ) {
final RegistryBuilder<ConnectionSocketFactory> registryBuilderToUse;
if ( registryBuilder == null ) {
registryBuilderToUse =
RegistryBuilder.<ConnectionSocketFactory> create ().register ( HTTP_SCHEME, PlainConnectionSocketFactory.INSTANCE ).register (
ApacheHttpClientConnectionManagerFactory.HTTPS_SCHEME, SSLConnectionSocketFactory.getSocketFactory () );
} else {
registryBuilderToUse = registryBuilder;
}
return super.newConnectionManager ( disableSslValidation, maxTotalConnections, maxConnectionsPerRoute, timeToLive, timeUnit,
registryBuilderToUse );
}
};
}
}
because org.springframework.cloud.netflix.zuul.filters.route.SimpleHostRoutingFilter.initialize() calls the org.springframework.cloud.commons.httpclient.ApacheHttpClientConnectionManagerFactory.newConnectionManager(boolean, int, int, long, TimeUnit, RegistryBuilder) method always with NULL (as long as you don't supply a custom HTTPClient)
Same ran into the same issue with Edgware.RELEASE
This was fixed in https://github.com/spring-cloud/spring-cloud-commons/pull/278 and will be in Edgware.SR1
Any plan for Edgware.SR1 release ?
@ch4mpy we are in the process of doing the release now
@ryanjbaxter I think the property is confusing now, the property is zuul.sslHostnameValidationEnabled and is passed as parameter to ApacheHttpClientConnectionManagerFactory#newConnectionManager to the parameter disableSslValidation.
So it is passing the opposite value.
@lchayoun see #2503