inductiveautomation / ignition-module-tools

Tools that help in the creation and development of Modules for Inductive Automation's Ignition.
48 stars 12 forks source link

Provide better error message if certAlias is wrong in SignModule #60

Open magnus-puresalmon opened 1 week ago

magnus-puresalmon commented 1 week ago

Currently, if using a pfx keystore and specifying the wrong certificate alias, the keystore returns null for

val privateKey: PrivateKey = keyStore.getKey(
            certAlias,
            certPassword?.toCharArray()
        ) as PrivateKey

which then throws null cannot be cast to non-null type java.security.PrivateKey from line 360 in the SignModule.kt file, rather than informing the user that the requested alias was not found.

brianeray commented 1 week ago

Thanks for filing this. It's interesting that a "miss" on the alias works like a Map key miss, just returning null. There are exceptions thrown by other sorts of getKey failures but this does not rise to that bar for Java.

In any case, easy enough to trap and throw a meaningful exception. This is IGN-10929 in our internal tracker.