micronaut-projects / micronaut-core

Micronaut Application Framework
http://micronaut.io
Apache License 2.0
6.07k stars 1.07k forks source link

Service SSL configuration is being ignored #1708

Closed carlosbarragan closed 5 years ago

carlosbarragan commented 5 years ago

Thanks for reporting an issue for Micronaut, please review the task list below before submitting the issue. Your issue report will be closed if the issue is incomplete and the below tasks not completed.

NOTE: If you are unsure about something and the issue is more of a question a better place to ask questions is on Stack Overflow (http://stackoverflow.com/tags/micronaut) or Gitter (https://gitter.im/micronautfw/). DO NOT use the issue tracker to ask questions.

Task List

Steps to Reproduce

  1. Configure a service as follows
http:
  services:
     myservice:
        url: https//somehost.com
        ssl-configuration:  
          enable: true
          key-store:
            path: classpath:PATH_TO_CERTIFICATE.pfx
            type: PKCS12
            password: ${certificate.password}

Expected Behaviour

Configuration should be taken into account and therefore, it is possible to call the service with the specified certificate.

Actual Behaviour

SSL Handshake failure error occurred.

Caused by: javax.net.ssl.SSLException: Received fatal alert: handshake_failure
    at sun.security.ssl.Alerts.getSSLException(Alerts.java:208)
    at sun.security.ssl.SSLEngineImpl.fatal(SSLEngineImpl.java:1666)
    at sun.security.ssl.SSLEngineImpl.fatal(SSLEngineImpl.java:1634)
    at sun.security.ssl.SSLEngineImpl.recvAlert(SSLEngineImpl.java:1800)
    at sun.security.ssl.SSLEngineImpl.readRecord(SSLEngineImpl.java:1083)
    at sun.security.ssl.SSLEngineImpl.readNetRecord(SSLEngineImpl.java:907)
    at sun.security.ssl.SSLEngineImpl.unwrap(SSLEngineImpl.java:781)
    at javax.net.ssl.SSLEngine.unwrap(SSLEngine.java:624)

The configuration works if I configure the default client like this:

 http:
    services:
      my-service:
        url: https//somehost.com
      ssl-configuration:
        enable: true
    client:
      ssl:
        enable: true
        key-store:
          path: classpath:PATH_TO_CERTIFICATE.pfx
          type: PKCS12
          password: ${certificate.password}

I am able to call the service with the certificate and everything works fine.

Environment Information

Example Application

I don't have one since the certificate stuff is not public.

sdelamo commented 5 years ago

I believe the indentation in your issue report is incorrect:

Screenshot_23_05_2019__13_36
carlosbarragan commented 5 years ago

@sdelamo sorry, I fixed it.

carlosbarragan commented 5 years ago

@jameskleeh I updated my project to the 1.1.3 and I can now verify that the configuration is being picked up, however, it seems that it is still ignored when making the client call. I still get a handshake error.

If I configure the default client with ssl it works.

Another thing I noticed is that the proper way to configure the service ssl is to use the ssl key instead of ssl-configuration like this:

http:
  services:
     myservice:
        url: https//somehost.com
        ssl:  
          enable: true

So, to sum up, the following configuration still does not work:

http:
  services:
     myservice:
        url: https//somehost.com
        ssl:  
          enable: true
          key-store:
            path: classpath:PATH_TO_CERTIFICATE.pfx
            type: PKCS12
            password: ${certificate.password}
carlosbarragan commented 5 years ago

So, it seems this bug is finally fixed in #2229

Is that right @jameskleeh ?

jameskleeh commented 5 years ago

@carlosbarragan Thats right. Back when this was reported the issue had multiple layers and I fixed the first one. I didn't see your comment in July. Had I seen it the issue may have been fixed much sooner. In the future file a new issue so it will be more visible.

carlosbarragan commented 5 years ago

@jameskleeh no problem, I just wanted to be sure the other issue is related to this.

Thanks!