Hi Addie
I fixed this in [1] by throwing a better exception: I actually test
right at the start if the secret key supports encoding, and throw an
exception *right away* if it doesn't. I also allude to FIPS being
enabled in the error message as a possible cause.
Commits are on master, 5.2.x and 4.x branches.
Please let me know if this works for you,
Cheers
[1]
https://issues.redhat.com/browse/JGRP-2734
On 11.10.23 23:04, Addie Drake wrote:
> Not sure if my last message went through (I also may have clicked the
> wrong reply button) so just wanted to reiterate here.
>
> Adding the stack trace to the log.error in createNewKey would help avoid
> confusion in the future, but to go farther, could also add a log error
> in initSymCiphers if secret.getEncoded() is null with a message like
> "secret key does not support encoding".
>
> My solution to getting JGroups working on a RHEL 8 system with FIPS enabled:
>
> 1. Install bc-fips (
https://www.bouncycastle.org/fips-java/) somewhere
> in the system classpath
> 2. Configure java.security and add the new BCFIPS provider. My
> fips.providers look like this:
>
> #
> # Security providers used when FIPS mode support is active
> #
> fips.provider.1=org.bouncycastle.jcajce.provider.BouncyCastleFipsProvider
> fips.provider.2=com.sun.net.ssl.internal.ssl.Provider BCFIPS
> fips.provider.3=sun.security.pkcs11.SunPKCS11
> ${java.home}/lib/security/nss.fips.cfg
> fips.provider.4=sun.security.provider.Sun
> fips.provider.5=sun.security.ec.SunEC
> 3. Restart Tomcat
>
> Running the test.java example I gave previously, this is the result:
>
> *with fips enabled, SunPKCS11-NSS-FIPS default provider*
> # java test
> SunPKCS11-NSS-FIPS version 1.8
> AES
> null
> null
>
> *with fips disabled, SunJCE default provider*
> # java -Dcom.redhat.fips=false test
> SunJCE version 1.8
> AES
> RAW
> [B@2c7b84de
>
> *with fips enabled, BCFIPS default provider*
> # java test
> BCFIPS version 1.000204
> AES
> RAW
> [B@5fa23c*
> *
>
> Thanks again,
> Addie
>
> On Monday, October 9, 2023 at 3:28:24 AM UTC-4 Bela Ban wrote:
>
> So I assume throwing the exception correctly (instead of an NPE) is the
> solution here? So that people know that a given encryption alg is not
> supported, and this is a configuration error?
>
> On 05.10.23 00:33, Addie Drake wrote:
> > Hi all,
> >
> > I may have found where it's actually breaking after scouring the
> JGroups
> > 4.1.7 source:
> >
> >
>
https://github.com/belaban/JGroups/blob/JGroups-4.1.7.Final/src/org/jgroups/protocols/Encrypt.java#L242 <
https://github.com/belaban/JGroups/blob/JGroups-4.1.7.Final/src/org/jgroups/protocols/Encrypt.java#L242> <
https://github.com/belaban/JGroups/blob/JGroups-4.1.7.Final/src/org/jgroups/protocols/Encrypt.java#L242 <
https://github.com/belaban/JGroups/blob/JGroups-4.1.7.Final/src/org/jgroups/protocols/Encrypt.java#L242>>
>
https://docs.oracle.com/javase/8/docs/api/java/security/Key.html#getEncoded-- <
https://docs.oracle.com/javase/8/docs/api/java/security/Key.html#getEncoded--> <
https://docs.oracle.com/javase/8/docs/api/java/security/Key.html#getEncoded-- <
https://docs.oracle.com/javase/8/docs/api/java/security/Key.html#getEncoded-->> , getEncoded is supposed to return "the encoded key, or null if the key does not support encoding."
>
https://github.com/belaban/JGroups/blob/JGroups-4.1.7.Final/src/org/jgroups/protocols/ASYM_ENCRYPT.java#L550 <
https://github.com/belaban/JGroups/blob/JGroups-4.1.7.Final/src/org/jgroups/protocols/ASYM_ENCRYPT.java#L550> <
https://github.com/belaban/JGroups/blob/JGroups-4.1.7.Final/src/org/jgroups/protocols/ASYM_ENCRYPT.java#L550 <
https://github.com/belaban/JGroups/blob/JGroups-4.1.7.Final/src/org/jgroups/protocols/ASYM_ENCRYPT.java#L550>>
>
https://groups.google.com/d/msgid/jgroups-dev/6aa736a9-9068-4d2b-a679-0e208ce4a3b2n%40googlegroups.com <
https://groups.google.com/d/msgid/jgroups-dev/6aa736a9-9068-4d2b-a679-0e208ce4a3b2n%40googlegroups.com> <
https://groups.google.com/d/msgid/jgroups-dev/6aa736a9-9068-4d2b-a679-0e208ce4a3b2n%40googlegroups.com?utm_medium=email&utm_source=footer <
https://groups.google.com/d/msgid/jgroups-dev/6aa736a9-9068-4d2b-a679-0e208ce4a3b2n%40googlegroups.com?utm_medium=email&utm_source=footer>>.
> >
> > --
> > You received this message because you are subscribed to the Google
> > Groups "jgroups-dev" group.
> > To unsubscribe from this group and stop receiving emails from it,
> send
> > an email to
jgroups-dev...@googlegroups.com
> > <mailto:
jgroups-dev...@googlegroups.com>.
> > To view this discussion on the web visit
> >
>
https://groups.google.com/d/msgid/jgroups-dev/b516830c-8d2d-4526-a220-2e424e080ecan%40googlegroups.com <
https://groups.google.com/d/msgid/jgroups-dev/b516830c-8d2d-4526-a220-2e424e080ecan%40googlegroups.com> <
https://groups.google.com/d/msgid/jgroups-dev/b516830c-8d2d-4526-a220-2e424e080ecan%40googlegroups.com?utm_medium=email&utm_source=footer <
https://groups.google.com/d/msgid/jgroups-dev/b516830c-8d2d-4526-a220-2e424e080ecan%40googlegroups.com?utm_medium=email&utm_source=footer>>.
>
> --
> Bela Ban |
http://www.jgroups.org <
http://www.jgroups.org>
>
> --
> You received this message because you are subscribed to the Google
> Groups "jgroups-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to
jgroups-dev...@googlegroups.com
> <mailto:
jgroups-dev...@googlegroups.com>.
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/jgroups-dev/57a5a346-f2e3-43aa-a2c9-fd9ef460a6fen%40googlegroups.com <
https://groups.google.com/d/msgid/jgroups-dev/57a5a346-f2e3-43aa-a2c9-fd9ef460a6fen%40googlegroups.com?utm_medium=email&utm_source=footer>.