Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #39897 > unrolled thread
| Started by | Andreas Leitgeb <avl@logic.at> |
|---|---|
| First post | 2023-01-26 18:59 +0000 |
| Last post | 2023-02-08 15:37 +0100 |
| Articles | 7 — 4 participants |
Back to article view | Back to comp.lang.java.programmer
Alternative for properties like javax.net.ssl.trustStorePassword ... Andreas Leitgeb <avl@logic.at> - 2023-01-26 18:59 +0000
Re: Alternative for properties like javax.net.ssl.trustStorePassword ... "e.d.pro...@gmail.com" <e.d.programmer@gmail.com> - 2023-01-26 12:50 -0800
Re: Alternative for properties like javax.net.ssl.trustStorePassword ... Andreas Leitgeb <avl@logic.at> - 2023-01-31 23:30 +0000
Re: Alternative for properties like javax.net.ssl.trustStorePassword ... "e.d.pro...@gmail.com" <e.d.programmer@gmail.com> - 2023-02-01 04:25 -0800
Re: Alternative for properties like javax.net.ssl.trustStorePassword ... Arne Vajhøj <arne@vajhoej.dk> - 2023-01-26 16:50 -0500
Re: Alternative for properties like javax.net.ssl.trustStorePassword ... Andreas Leitgeb <avl@logic.at> - 2023-01-31 23:51 +0000
Re: Alternative for properties like javax.net.ssl.trustStorePassword ... Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2023-02-08 15:37 +0100
| From | Andreas Leitgeb <avl@logic.at> |
|---|---|
| Date | 2023-01-26 18:59 +0000 |
| Subject | Alternative for properties like javax.net.ssl.trustStorePassword ... |
| Message-ID | <slrntt5jd0.pa7s.avl@logic.at> |
If some java appliation is supposed to use a trustStore, then apparently all hits on google for the obvious words will suggest to start the application with an option "-Djavax.net.ssl.trustStorePassword=..." passed to the java executable... Assuming I do not want everyone on the machine to see the password in clear text in the "ps -ef" output, what would be "safer" alternatives? The most obvious one might be to set the property from my own code, (after reading the pw from a file that not everyone on the machine has access to) but my code comes too late: some beans already got initialized and didn't see the property, before the program gets to set the properties. -- I'm not a master of beans... maybe I could just add another bean that would do the "setProperty" as a sideeffect just in time before the other bean needs the property... haven't thought this through, yet. Maybe I'm still in the stone-age, and there is already some new property that would allow me to just specify another file holding the relevant passwords, or something else? Any ideas? Is passing a password as argument to a process nothing to worry about?
[toc] | [next] | [standalone]
| From | "e.d.pro...@gmail.com" <e.d.programmer@gmail.com> |
|---|---|
| Date | 2023-01-26 12:50 -0800 |
| Message-ID | <98e07321-e56e-4546-b62b-9d614deedf79n@googlegroups.com> |
| In reply to | #39897 |
> Any ideas? Is passing a password as argument to a process nothing to worry > about? first result https://docs.oracle.com/javadb/10.8.3.0/adminguide/cadminsslclient.html shows setting the password as system property right before making your first database connection. How and when are you making your database connection? I normally make database connections using datasource in the tomcat config files with the password in the config as an encrypted string and reference a decryption jar.
[toc] | [prev] | [next] | [standalone]
| From | Andreas Leitgeb <avl@logic.at> |
|---|---|
| Date | 2023-01-31 23:30 +0000 |
| Message-ID | <slrnttj940.pa7s.avl@logic.at> |
| In reply to | #39898 |
e.d.pro...@gmail.com <e.d.programmer@gmail.com> wrote: >> Any ideas? Is passing a password as argument to a process nothing to worry >> about? > first result https://docs.oracle.com/javadb/10.8.3.0/adminguide/cadminsslclient.html > shows setting the password as system property right before making > your first database connection. How and when are you making your > database connection? It is a web-application running in tomcat, and tomcat itself is currently configured in "bin/setenv.sh" to start with those "-D..." options, setting key- & truststore file and their password. > I normally make database connections using datasource in the tomcat > config files with the password in the config as an encrypted string > and reference a decryption jar. That sounds like a promising solution... Could I set them e.g. in the server.xml ? The tomcat-config is already readable only by the user running it, which would be a huge advantage to current state where the password shows up in process list visible even for other users.
[toc] | [prev] | [next] | [standalone]
| From | "e.d.pro...@gmail.com" <e.d.programmer@gmail.com> |
|---|---|
| Date | 2023-02-01 04:25 -0800 |
| Message-ID | <dd2dc8fe-e04a-43aa-953a-ad0a6949e15an@googlegroups.com> |
| In reply to | #39904 |
> That sounds like a promising solution... > Could I set them e.g. in the server.xml ? > I'm not an expert on what server.xml can do but database config that I've seen is normally in context.xml. Just paste the encrypted string in a resource tag, use a factory to reference the decryption method, and drop your jdbc jar and decryption jar in the tomcat lib folder. https://stackoverflow.com/a/48179892
[toc] | [prev] | [next] | [standalone]
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Date | 2023-01-26 16:50 -0500 |
| Message-ID | <tqusjt$1bq63$1@dont-email.me> |
| In reply to | #39897 |
On 1/26/2023 1:59 PM, Andreas Leitgeb wrote: > If some java appliation is supposed to use a trustStore, then apparently > all hits on google for the obvious words will suggest to start the application > with an option "-Djavax.net.ssl.trustStorePassword=..." passed to the java > executable... > > Assuming I do not want everyone on the machine to see the password in clear > text in the "ps -ef" output, what would be "safer" alternatives? > > The most obvious one might be to set the property from my own code, (after > reading the pw from a file that not everyone on the machine has access to) > but my code comes too late: some beans already got initialized and didn't > see the property, before the program gets to set the properties. -- > I'm not a master of beans... maybe I could just add another bean that > would do the "setProperty" as a sideeffect just in time before the other > bean needs the property... haven't thought this through, yet. > > Maybe I'm still in the stone-age, and there is already some new property that > would allow me to just specify another file holding the relevant passwords, > or something else? > > Any ideas? Is passing a password as argument to a process nothing to worry > about? A password in visible plain text is at least a potential problem. But there are no miracles. You have some code that are not yours that use this property. Your regular code that runs later cannot change that property when needed. You need to get some code to run before the code using this property. Startup servlet may be too unreliable timing wise. Some googling indicate that a ServletContextListener and doing it in contextInitialized may be better. If everything is using Spring you may be able to sneak some code in via Spring early enough. If they will allow you to use sledgehammer then a Java agent will run before anything! Arne
[toc] | [prev] | [next] | [standalone]
| From | Andreas Leitgeb <avl@logic.at> |
|---|---|
| Date | 2023-01-31 23:51 +0000 |
| Message-ID | <slrnttjabt.pa7s.avl@logic.at> |
| In reply to | #39899 |
Arne Vajhøj <arne@vajhoej.dk> wrote:
> On 1/26/2023 1:59 PM, Andreas Leitgeb wrote:
>> Any ideas? Is passing a password as argument to a process nothing to worry
>> about?
> A password in visible plain text is at least a potential problem.
>
> You have some code that are not yours that use this property.
> Your regular code that runs later cannot change that property when needed.
> You need to get some code to run before the code using this property.
> Startup servlet may be too unreliable timing wise.
> Some googling indicate that a ServletContextListener and doing
> it in contextInitialized may be better.
Actually, my hope was, that I wouldn't really need any own code for
that at all.
Alternatives could in principle be:
- newer properties with an extra level of indirection for the sensible
data, ideally understood by the same (java crypto internal) code
that currently reads these "indiscrete" properties...
I didn't find any from googling, but that doesn't necessarily mean
that there couldn't be any.
- Given that my app runs in tomcat, maybe tomcat already has a way to
specify properties in its configuration (outside setenv.sh)...
(I didn't think of that until e.d.programmer mentioned tomcat config
in his followup. I'm not sure if he meant it that way: as defining
properties somewhere inside e.g. the xmls or some property-files that
would be read by tomcat after startup)
- maybe others...
[toc] | [prev] | [next] | [standalone]
| From | Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> |
|---|---|
| Date | 2023-02-08 15:37 +0100 |
| Message-ID | <ts0c35$74ft$1@dont-email.me> |
| In reply to | #39897 |
On 26/01/2023 19:59, Andreas Leitgeb wrote: > If some java appliation is supposed to use a trustStore, then apparently > all hits on google for the obvious words will suggest to start the application > with an option "-Djavax.net.ssl.trustStorePassword=..." passed to the java > executable... > > Assuming I do not want everyone on the machine to see the password in clear > text in the "ps -ef" output, what would be "safer" alternatives? > > The most obvious one might be to set the property from my own code, (after > reading the pw from a file that not everyone on the machine has access to) > but my code comes too late: some beans already got initialized and didn't > see the property, before the program gets to set the properties. -- > I'm not a master of beans... maybe I could just add another bean that > would do the "setProperty" as a sideeffect just in time before the other > bean needs the property... haven't thought this through, yet. > > Maybe I'm still in the stone-age, and there is already some new property that > would allow me to just specify another file holding the relevant passwords, > or something else? > > Any ideas? Is passing a password as argument to a process nothing to worry > about? > A password in the clear, stored somewhere on disk, is always something to worry about. But I think the only way to solve the conundrum is to leverage the OS and, more precisely, its user management. Make the truststore file readable to the Tomcat user (and su) only. Then you could perhaps even dispense with a password on the TS (although it'd probably better not to). Or leverage some kind of secure storage that's freely accessible to the user, but to the user only, to retrieve the password (be it a mere file or a cryptographically-secured safe). I don't know of any other way. There might be some. I somewhat doubt it. Security is easy once you're in it. Bootstrapping it, is a can of worms. > The tomcat-config is already readable only by the user running it, > which would be a huge advantage to current state where the password > shows up in process list visible even for other users. Well, there you go. This <https://www.cyberciti.biz/faq/linux-hide-processes-from-other-users/> seems possibly relevant, too. -- DF.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.programmer
csiph-web