Skip to content
This repository has been archived by the owner on Feb 23, 2023. It is now read-only.

runtime certificates loading for truststore #1434

Closed
neoludo opened this issue Jan 10, 2022 · 13 comments
Closed

runtime certificates loading for truststore #1434

neoludo opened this issue Jan 10, 2022 · 13 comments
Labels
status: feedback-provided Feedback has been provided status: waiting-for-triage An issue we've not yet triaged or decided on

Comments

@neoludo
Copy link

neoludo commented Jan 10, 2022

HI there,

I've followed instructions at https://paketo.io/docs/howto/configuration/#ca-certificates to add certificates at runtime.
I can see that log at startup :
Added 3 additional CA certificate(s) to system truststore

But when I'm listing certificates from inside my app, I dont see the 3 added certificates...
It seems that build-time truststore is used....
I should have missed a step.

Can anyone help me, plz ?

Thanks
Ludo

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jan 10, 2022
@sdeleuze
Copy link
Contributor

You may find the answer in paketo-buildpacks/graalvm#66, please let us know how it goes, happy to improve the documentation if needed.

@sdeleuze sdeleuze added the status: waiting-for-feedback We need additional information before we can continue label Jan 14, 2022
@matthyx
Copy link

matthyx commented Jan 14, 2022

@sdeleuze I think @neoludo wants to load the truststore at runtime, as recently added to graalvm:
https://www.graalvm.org/reference-manual/native-image/CertificateManagement/#run-time-options

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Jan 14, 2022
@sdeleuze
Copy link
Contributor

Thanks for the link @matthyx, I was missed the fact it was properly documented now. I think such documentation on native image official documentation is good enough so I close this issue.

@sdeleuze sdeleuze added type: question A question and removed status: waiting-for-triage An issue we've not yet triaged or decided on status: feedback-provided Feedback has been provided labels Jan 14, 2022
@matthyx
Copy link

matthyx commented Jan 14, 2022

@sdeleuze hmm, not sure as it's not clear to me how you can specify javax.net.ssl.trustStore and javax.net.ssl.trustStorePassword to the native image from the container image.

One solution is to override the container entrypoint and/or arguments, but it's against the whole buildpack philosophy, isn't it?

@sdeleuze
Copy link
Contributor

Ok let's discuss that with @scottfrederick and @dmikusa-pivotal then.

@sdeleuze sdeleuze reopened this Jan 14, 2022
@sdeleuze sdeleuze added status: waiting-for-triage An issue we've not yet triaged or decided on and removed type: question A question labels Jan 14, 2022
@matthyx
Copy link

matthyx commented Jan 14, 2022

Ok let's discuss that with @scottfrederick and @dmikusa-pivotal then.

Do you mean in this issue?

@dmikusa
Copy link

dmikusa commented Jan 15, 2022

If you want to send additional arguments to the native-image command at build time, you can do that by setting $BP_NATIVE_IMAGE_BUILD_ARGUMENTS. Your arguments are augmented by the buildpack which adds the following information (you don't need/want to include this manually):

  1. When on the tiny stack, -H:+StaticExecutableWithDynamicLibC will be appended to your custom argument list.
  2. -H:Name= is appended to the custom argument list where the value is set as the full path to the start class
  3. -cp is set with the full classpath
  4. The start class is added to the end of the command

If you want to supply arguments at runtime, you can do that using these instructions. This will let you pass additional arguments to the default command used to run your application.


In terms of javax.net.ssl.trustStore we don't generally recommend setting this value directly for Java applications running on a JVM. If you follow the recommended instructions for adding trusted CA certificates, this will result in the certificates being added to the default system truststore, i.e. /etc/ssl/certs/ca-certificates.crt and to the default truststore for the JVM.

In terms of native image builds, I think this advice would apply as well (I'm open to discussing this though as native image is new). The additional trusted certificates should be loaded into the JVM truststore when the JVM and native-image tool are installed. This means that they should be present, which according to the docs should be sufficient:

During the image building process, the native-image builder captures the host environment’s default TrustStore and embeds it into the native executable.

When I last checked this on paketo-buildpacks/graalvm#66 things just worked. I haven't tried this lately though, so if it's not working. Let's take a look and see what's happening. To do that, please include the full output from your build plus any build config (i.e. env variables, buildpack ordering, that you're customizing).

That said, I see no reason why setting the arguments would be a problem. You'd need to use the options above to pass those additional arguments through at run/build time as required by native-image. Please give that a try and let me know how things go.

@matthyx
Copy link

matthyx commented Jan 15, 2022

please ignore, this was answered too quickly without full context
@dmikusa-pivotal please note we're talking about RUNTIME arguments.
I think @neoludo wants to avoid overriding ENTRYPOINT and CMD in the resulting image in case paketo sets something special during build.

@matthyx
Copy link

matthyx commented Jan 15, 2022

@dmikusa-pivotal, after reading on my laptop (rather than my mobile) I see what you mean... apologizes.

If you follow the recommended instructions for adding trusted CA certificates, this will result in the certificates being added to the default system truststore, i.e. /etc/ssl/certs/ca-certificates.crt and to the default truststore for the JVM.

@neoludo already played with https://github.com/paketo-buildpacks/ca-certificates and at runtime it can add trusted certificates to the system truststore...
The issue is that in native mode it only creates /etc/ssl/certs/ca-certificates.crt and no JKS... which substrateVM doesn't handle (despite my suggestion).

So I think we need to modify the buildpack to generate a JKS and inject the required arguments for using it.

@dmikusa
Copy link

dmikusa commented Jan 17, 2022

The issue is that in native mode it only creates /etc/ssl/certs/ca-certificates.crt and no JKS... which substrateVM doesn't handle (despite my suggestion).

I agree. I added an issue under the native image repo to track this for us. We'll look into this more.

@matthyx
Copy link

matthyx commented Jan 17, 2022

Thanks @dmikusa-pivotal !

@sdeleuze
Copy link
Contributor

Should I close this issue ?

@sdeleuze sdeleuze added the status: waiting-for-feedback We need additional information before we can continue label Jan 31, 2022
@matthyx
Copy link

matthyx commented Feb 1, 2022

@sdeleuze I agree this issue is more related to a change in the buildpack... we can close this but let's hope @dmikusa-pivotal work goes to completion.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Feb 1, 2022
@sdeleuze sdeleuze closed this as completed Feb 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: feedback-provided Feedback has been provided status: waiting-for-triage An issue we've not yet triaged or decided on
Development

No branches or pull requests

5 participants