Uploaded image for project: 'Red Hat Fuse'
  1. Red Hat Fuse
  2. ENTESB-10113

Can't use rest-swagger component with swagger.json provided over HTTPS protocol

    XMLWordPrintable

Details

    • Bug
    • Status: Done
    • Major
    • Resolution: Done
    • fuse-7.3
    • fuse-7.7-GA
    • Camel, Fuse Standalone
    • None

    Description

      I am not able to use rest-swagger component with https protocol.

      Example

      from("timer:x").to("rest-swagger:https://localhost:4444/swagger.json#user")
      
      FailedToCreateProducerException - Failed to create Producer for endpoint: rest-swagger://https://localhost:4444/swagger.json%23user. Reason: java.lang.IllegalArgumentException: The given Swagger specification could not be loaded from `https://localhost:4444/swagger.json`. Tried loading using Camel's resource resolution and using Swagger's own resource resolution. Swagger tends to swallow exceptions while parsing, try specifying Java system property `debugParser` (e.g. `-DdebugParser=true`), the exception that occured when loading using Camel's resource loader follows]
      
      org.apache.camel.FailedToCreateProducerException: Failed to create Producer for endpoint: rest-swagger://https://localhost:4444/swagger.json%23user. Reason: java.lang.IllegalArgumentException: The given Swagger specification could not be loaded from `https://localhost:4444/swagger.json`. Tried loading using Camel's resource resolution and using Swagger's own resource resolution. Swagger tends to swallow exceptions while parsing, try specifying Java system property `debugParser` (e.g. `-DdebugParser=true`), the exception that occured when loading using Camel's resource loader follows
      	at org.apache.camel.impl.ProducerCache.doGetProducer(ProducerCache.java:584) ~[camel-core-2.21.0.fuse-730042.jar:2.21.0.fuse-730042]
      	at org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:410) ~[camel-core-2.21.0.fuse-730042.jar:2.21.0.fuse-730042]
      	at org.apache.camel.processor.SendDynamicProcessor.process(SendDynamicProcessor.java:127) ~[camel-core-2.21.0.fuse-730042.jar:2.21.0.fuse-730042]
      	at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:548) ~[camel-core-2.21.0.fuse-730042.jar:2.21.0.fuse-730042]
      	at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201) [camel-core-2.21.0.fuse-730042.jar:2.21.0.fuse-730042]
      	at org.apache.camel.processor.Pipeline.process(Pipeline.java:138) ~[camel-core-2.21.0.fuse-730042.jar:2.21.0.fuse-730042]
      	at org.apache.camel.processor.Pipeline.process(Pipeline.java:101) ~[camel-core-2.21.0.fuse-730042.jar:2.21.0.fuse-730042]
      	at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201) [camel-core-2.21.0.fuse-730042.jar:2.21.0.fuse-730042]
      	at org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:197) [camel-core-2.21.0.fuse-730042.jar:2.21.0.fuse-730042]
      	at org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:79) [camel-core-2.21.0.fuse-730042.jar:2.21.0.fuse-730042]
      	at java.util.TimerThread.mainLoop(Timer.java:555) [na:1.8.0_191]
      	at java.util.TimerThread.run(Timer.java:505) [na:1.8.0_191]
      Caused by: java.lang.IllegalArgumentException: The given Swagger specification could not be loaded from `https://localhost:4444/swagger.json`. Tried loading using Camel's resource resolution and using Swagger's own resource resolution. Swagger tends to swallow exceptions while parsing, try specifying Java system property `debugParser` (e.g. `-DdebugParser=true`), the exception that occured when loading using Camel's resource loader follows
      	at org.apache.camel.component.rest.swagger.RestSwaggerEndpoint.loadSpecificationFrom(RestSwaggerEndpoint.java:580) ~[camel-rest-swagger-2.21.0.fuse-730042.jar:2.21.0.fuse-730042]
      	at org.apache.camel.component.rest.swagger.RestSwaggerEndpoint.createProducer(RestSwaggerEndpoint.java:168) ~[camel-rest-swagger-2.21.0.fuse-730042.jar:2.21.0.fuse-730042]
      	at org.apache.camel.impl.ProducerCache.doGetProducer(ProducerCache.java:573) ~[camel-core-2.21.0.fuse-730042.jar:2.21.0.fuse-730042]
      	... 11 common frames omitted
      Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
      	at sun.security.ssl.Alerts.getSSLException(Alerts.java:192) ~[na:1.8.0_191]
      	at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1946) ~[na:1.8.0_191]
      	at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:316) ~[na:1.8.0_191]
      	at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:310) ~[na:1.8.0_191]
      	at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1639) ~[na:1.8.0_191]
      	at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:223) ~[na:1.8.0_191]
      	at sun.security.ssl.Handshaker.processLoop(Handshaker.java:1037) ~[na:1.8.0_191]
      	at sun.security.ssl.Handshaker.process_record(Handshaker.java:965) ~[na:1.8.0_191]
      	at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1064) ~[na:1.8.0_191]
      	at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1367) ~[na:1.8.0_191]
      	at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1395) ~[na:1.8.0_191]
      	at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1379) ~[na:1.8.0_191]
      	at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:559) ~[na:1.8.0_191]
      	at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185) ~[na:1.8.0_191]
      	at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1564) ~[na:1.8.0_191]
      	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492) ~[na:1.8.0_191]
      	at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:263) ~[na:1.8.0_191]
      	at org.apache.camel.util.ResourceHelper.resolveResourceAsInputStream(ResourceHelper.java:241) ~[camel-core-2.21.0.fuse-730042.jar:2.21.0.fuse-730042]
      	at org.apache.camel.util.ResourceHelper.resolveMandatoryResourceAsInputStream(ResourceHelper.java:172) ~[camel-core-2.21.0.fuse-730042.jar:2.21.0.fuse-730042]
      	at org.apache.camel.component.rest.swagger.RestSwaggerEndpoint.loadSpecificationFrom(RestSwaggerEndpoint.java:568) ~[camel-rest-swagger-2.21.0.fuse-730042.jar:2.21.0.fuse-730042]
      	... 13 common frames omitted
      Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
      	at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:397) ~[na:1.8.0_191]
      	at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:302) ~[na:1.8.0_191]
      	at sun.security.validator.Validator.validate(Validator.java:262) ~[na:1.8.0_191]
      	at sun.security.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:324) ~[na:1.8.0_191]
      	at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:229) ~[na:1.8.0_191]
      	at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:124) ~[na:1.8.0_191]
      	at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1621) ~[na:1.8.0_191]
      	... 28 common frames omitted
      Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
      	at sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBuilder.java:141) ~[na:1.8.0_191]
      	at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:126) ~[na:1.8.0_191]
      	at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:280) ~[na:1.8.0_191]
      	at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:392) ~[na:1.8.0_191]
      	... 34 common frames omitted
      

      See more in attached reproducer.

      It seems that camel can't load swagger.json. This resource is loaded by ResourceHelper which is not able to consume resources over https.

      I have no option to set valid certificate.

      Attachments

        Issue Links

          Activity

            People

              jondruse@redhat.com Jiri Ondrusek
              jbouska@redhat.com Jan Bouska
              Jan Bouska Jan Bouska
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: