# How can we perform code signing using an HSM with module-signer?

**URL:** <https://forum.inductiveautomation.com/t/how-can-we-perform-code-signing-using-an-hsm-with-module-signer/85640>\
**Category:** Module Development\
**Created:** [February 13, 2024, 5:04pm UTC](https://forum.inductiveautomation.com/t/how-can-we-perform-code-signing-using-an-hsm-with-module-signer/85640 "2024-02-13T17:04:35Z")\
**Posts on this page:** 3\
**Page:** 2

<div class="post-metadata">

**Author:** ![Brian\_Ray](https://avatars.discourse-cdn.com/v4/letter/b/e0b2c6/32.png) [@Brian\_Ray](https://forum.inductiveautomation.com/u/Brian_Ray)\
**Post date:** [February 21, 2024, 12:04am UTC](https://forum.inductiveautomation.com/t/how-can-we-perform-code-signing-using-an-hsm-with-module-signer/85640/21 "2024-02-21T00:04:04Z")

</div>

UPDATE #2 2024-03-22

Hilarious, we still have some automation that successfully publishes to the Gradle Plugin Portal. It's [up there under Perrry's personal account](https://plugins.gradle.org/plugin/io.ia.sdk.modl).

So there is probably no custom configuration needed in `settings.gradle.kts` if you are already pulling from GPP.

* * *

UPDATE 2024-03-22

That PR has been merged and the Gradle plugin published to our `nexus.inductiveautomation.com` public repo. Make sure your Gradle project is using 7.6 or later for it to run reliably.

To use our Nexus repository for plugin resolution, add the following configuration to your `settings.gradle.kts` and `build.gradle.kts` (if using the Gradle Groovy DSL the syntax is similar):

```kotlin
// settings.gradle.kts

pluginManagement {
    repositories {
        maven {
            name = "publicNexusRelease"
            url = uri("https://nexus.inductiveautomation.com/repository/inductiveautomation-releases")
        }

        // if you want to use snapshot builds of the plugin
        // maven {
        // name = "publicNexusSnapshot"
        // url = uri("https://nexus.inductiveautomation.com/repository/inductiveautomation- // snapshots")
        // }

        gradlePluginPortal()

        // and any other plugin repos you may be using
    }
}

// build.gradle.kts

plugins {
    // any other plugins
    id("io.ia.sdk.modl") version "0.2.0"
}

```

For the time being we are not publishing to the [Gradle Plugin Portal](https://plugins.gradle.org/), even though an older version of this plugin is published there now. We're considering this down the road after ironing out some process issues.

* * *

Draft PR is up on GitHub.

[inductiveautomation/ignition-module-tools#43](https://github.com/inductiveautomation/ignition-module-tools/pull/43)

---

<div class="post-metadata">

**Author:** ![mostafa.gad](https://avatars.discourse-cdn.com/v4/letter/m/4491bb/32.png) [@mostafa.gad](https://forum.inductiveautomation.com/u/mostafa.gad)\
**Post date:** [April 29, 2026, 1:53pm UTC](https://forum.inductiveautomation.com/t/how-can-we-perform-code-signing-using-an-hsm-with-module-signer/85640/22 "2026-04-29T13:53:51Z")

</div>

Hello

I am trying to sign module using cloud HSM (gcp kms)

pkcs11 config file:

```python
name = CloudKMS

library = /tmp/libkmsp11.so

slotListIndex = 0

attributes(*, CKO_PRIVATE_KEY, *) = {

  CKA_SIGN = true

}

```

-------

libkmsp11.so library config

```python
tokens:

  - key_ring: "projects/${GCP_PROJECT}/locations/${KMS_KEY_LOCATION}/keyRings/${KMS_KEY_RING}"

```

--------

```python
    gradle signModule \
      --certAlias ${KMS_KEY_NAME} \
      --certFile /tmp/signing.crt \
      --pkcs11CfgFile /tmp/pkcs11.cfg 

```

error:  
`2026-04-29T13:38:23.747+0000 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * What went wrong:`  
`2026-04-29T13:38:23.748+0000 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Execution failed for task ':signModule'.`  
`2026-04-29T13:38:23.748+0000 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > null cannot be cast to non-null type java.security.PrivateKey`

SignModule.kt line 357  
`val privateKey: PrivateKey = keyStore.getKey( certAlias, certPassword?.toCharArray() ) as PrivateKey`

---

<div class="post-metadata">

**Author:** ![mostafa.gad](https://avatars.discourse-cdn.com/v4/letter/m/4491bb/32.png) [@mostafa.gad](https://forum.inductiveautomation.com/u/mostafa.gad)\
**Post date:** [April 29, 2026, 3:28pm UTC](https://forum.inductiveautomation.com/t/how-can-we-perform-code-signing-using-an-hsm-with-module-signer/85640/23 "2026-04-29T15:28:30Z")

</div>

> [@mostafa.gad](#):
>
> libkmsp11.so library config

I found my issue, it was in libkmsp11.so library config as per [this](https://github.com/GoogleCloudPlatform/kms-integrations/blob/e20449546ab4824f798fe553eaba0750294d5106/kmsp11/docs/user_guide.md#:~:text=Whether%20to%20generate,use%20is%20discouraged.) I need to set generate\_certs to true.

[Previous page](https://forum.inductiveautomation.com/t/how-can-we-perform-code-signing-using-an-hsm-with-module-signer/85640.md?page=1)
