-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support CA Certificates with native images #66
Comments
@scottfrederick Hi, we merged paketo-buildpacks/java-native-image#99 recently, which sounds like it addresses your request here. I just wanted to confirm though, as this is opened up under the Graalvm buildpack. Just want to make sure I'm not overlooking somewhere else where we need to add ca-certificates back. Thanks |
Hi, this request is about adding the certificates to the embedded jks keystore that is added to the executable at build time. |
I was going to check if I could propose a PR here, but if you're already familiar with buildpacks please go ahead (I'm a complete n00b here). |
FTR here is the graalVM PR: oracle/graal#3091 |
As @matthyx said, there's more to do here for GraalVM in the native image case. Good documentation on this is hard to find, but there's a good hint in the GraalVM javadocs. To fully support CA Certificates in this buildpack with native-image builds, I think what needs to happen is:
|
100% correct |
OK, thanks for the clarifications. Let me take a look at this tomorrow and see what we can do. |
Hi @dmikusa-pivotal any news? |
Well, the good news is that I think we are doing similar things in other buildpacks so it shouldn't be too hard to add this in here. It'll take some work but I have a couple of other priorities in my queue first, so I'd guess maybe 1-2 weeks for me to implement. If you are interested in getting it done more quickly and could send a PR, I can definitely make time to review/merge that in. |
Thanks @dmikusa-pivotal I think it's fine for a timeline. You'll probably make it better and faster than me... |
Digging some more, GraalVM buildpack is already running the code that should be importing container certs (and as far as I can tell, also ca-certs provided certs, into the JVM's default My suspicion was that you could make this work right now by setting I can see ca-certs buildpack running and importing my custom CA into the image. There is unfortunately no logging when GraalVM buildpack loads the container certs into the JVM default cert. I need to confirm this is happening as I expect. Failing that, I will have to poke at the native image build command a bit more. I was hoping to get this working before I start hacking at the code. It seems like the changes should be minimal, I just wanted to figure out specifically what needs to change. |
Awesome news @dmikusa-pivotal I will try to find some time today to try out the trick with |
OK, so I figured out what I was messing up yesterday. When I was merging updates recently, I messed up the order and the ca-certs buildpack was not running first. Thus GraalVM was running, importing the default set of certs, then ca-certs was running and adding my custom cert, but it was already too late because GraalVM had run and generated the cacerts file with the container certs. Anyway, after fixing this. It's working for me. So I set You should be able to use this now (although you'll need a custom java-native-image buildpack image at the moment since we haven't cut a release since adding ca-certs back into the buildpack). What I will do is automate this and have the native-image buildpack pass in this argument conditionally, based on the presence of the ca-certs binding. |
I'm also wondering if this is really necessary. The GraalVM buildpack is loading the ca-certificates provided certs into the default truststore for the JVM, i.e. @matthyx If you could try it without the argument too. Just make sure that you see these three key items in your build output.
In my case, when these three happened, native-image just did the right thing and pull in my custom cacerts. |
@dmikusa-pivotal I have tried to build a new version of the However I cannot test if that works, because |
Here is the error:
|
Sorry, let's see if we can make this easier to test.
The contents of the Let me know how that goes. |
Perfect, it works!
And even builds 'till the end:
Thank you so much for your support, now we're waiting for the 2.5.0 release. |
I was already using |
Fantastic! Thanks @matthyx for helping me test and work through this. Since I didn't have to change any code here, there's no new GraalVM version to cut. We do need to cut a new release of java-native-image though, to fix the ordering issue. That is presently held up for compatibility reasons, as I mentioned here -> paketo-buildpacks/java-native-image#99 (comment). In the meantime, feel free to use that temporary builder I pushed. I'll leave it published. Just make sure you switch once we cut the new release. I'll keep this issue open until we're able to cut the new release so you can get notifications. |
@matthyx Could you please share a sample application to help me writing proper documentation (tracked by spring-attic/spring-native#689)? |
Sure @sdeleuze let me fork the sample apps repo and make the modifications there... I cannot share our company apps on github. |
Please see my modifications in the webclient sample app: You have to build it using: |
I have just tested this with springBootVersion = '2.5.0' and it only works if i convert the certificates to the PEM format using the following command:
If the certificates are in the CRT format, then i get the following error:
Is this expected and we should always convert to PEM ? |
I think so: https://github.com/paketo-buildpacks/ca-certificates |
+1 they have to be PEM encoded, that's a requirement of ca-certificates. If that's a challenge, or you think we should permit other formats, you could open an issue against ca-certificates. |
I think this is fine from my point of view, we can convert them to be PEM encoded. |
Sorry for the delay. This work was released and the latest versions of Java Native Image buildpack should support CA certificates. |
When configuring a JDK or JRE, this buildpack will add any certificates provided by the CA Certificates buildpack to the JVM truststore. It does not appear that certificates provided by CA Certificates will be configured correctly when building a native image. Can support for CA Certificates in native images be added?
The text was updated successfully, but these errors were encountered: