Skip to content

Load files specified via properties from classpath #430

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

Closed
pmaedel opened this issue Aug 12, 2020 · 1 comment
Closed

Load files specified via properties from classpath #430

pmaedel opened this issue Aug 12, 2020 · 1 comment
Labels
for: external-project For an external project and not something we can fix

Comments

@pmaedel
Copy link

pmaedel commented Aug 12, 2020

I have a cert.pem in my src/main/resources
I need it when running the app jarred as well as unjarred.

Specifying it faithfully in my application.properties as spring.r2dbc.properties.sslRootCert=classpath:cert.pem fails as r2dbc does not load the file via classpath: https://github.com/pgjdbc/r2dbc-postgresql/blob/main/src/main/java/io/r2dbc/postgresql/util/Assert.java#L130

Caused by: java.lang.IllegalArgumentException: sslRootCert must not be null and must exist
	at io.r2dbc.postgresql.util.Assert.requireFileExistsOrNull(Assert.java:131) ~[r2dbc-postgresql-0.8.4.RELEASE.jar:0.8.4.RELEASE]
	at io.r2dbc.postgresql.PostgresqlConnectionConfiguration$Builder.sslRootCert(PostgresqlConnectionConfiguration.java:641) ~[r2dbc-postgresql-0.8.4.RELEASE.jar:0.8.4.RELEASE]

Workaround for running unjarred via Spring is to do the classpath lookup manually like this:

fun main() {
    val certFile = File(Application::class.java.classLoader.getResource("cert.pem")!!.toURI())
    System.setProperty("spring.r2dbc.properties.sslRootCert", certFile.path)

    runApplication<Application>()
}

I have not yet found a workaround to have the file loaded from within the jar.

I am unsure whether this should be addressed here or directly in r2dbc though.

@mp911de
Copy link
Member

mp911de commented Aug 12, 2020

The Postgres expects that files are loaded externally. This issue tracker is used for Spring Data R2DBC matters. Since the SSL certificate and other options are passed as Map<String, String>, there isn't much we can do here. Can you file a ticket in r2dbc-postgres to ask for supporting URL-based coordinates for SSL certificates? It would also make sense to raise a ticket in Spring Boot to explain your case and discuss options.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: external-project For an external project and not something we can fix
Projects
None yet
Development

No branches or pull requests

2 participants