Skip to content

Task to export key using option to encrypt with a password fails: Export failed with error: System.IO.IOException: PKCS12 key store MAC invalid - wrong password or corrupted file. #752

Description

@elkinweta

Using Certify The Web Hub v7.1.1.0 on Windows Server 2016 Essentials:

I have a renewed certificate. I created a task to export the private key to a .pem file.

When I do not use the option under Certificate > Advanced > Signing & Security > Security: "You can optionally specify a password credential to use for private keys and PFX files generated for this certificate", the task runs successfully and the key is exported.

When I store a password (Settings > Stored Credentials > Add Stored Credential > type = password) and then change the above option to use that stored password credential to encrypt the private key, then when I run the task it fails with this error:

Export failed with error: System.IO.IOException: PKCS12 key store MAC invalid - wrong password or corrupted file.
   at Org.BouncyCastle.Pkcs.Pkcs12Store.Load(Stream input, Char[] password)
   at Certify.Shared.Core.Utils.PKI.CertUtils.GetCertKeyPem(Byte[] pfxData, String pwd) in D:\a\certify-internal\certify-internal\src\certify-build\certify\src\Certify.Shared\Utils\PKI\CertUtils.cs:line 296
   at Certify.Shared.Core.Utils.PKI.CertUtils.GetCertComponentsAsPEMString(Byte[] pfxData, String pwd, ExportFlags flags, Boolean strictExport) in D:\a\certify-internal\certify-internal\src\certify-build\certify\src\Certify.Shared\Utils\PKI\CertUtils.cs:line 81
   at Certify.Shared.Core.Utils.PKI.CertUtils.GetCertComponentsAsPEMBytes(Byte[] pfxData, String pwd, ExportFlags flags, Boolean strictExport) in D:\a\certify-internal\certify-internal\src\certify-build\certify\src\Certify.Shared\Utils\PKI\CertUtils.cs:line 47
   at Certify.Providers.DeploymentTasks.CertificateExport.Execute(DeploymentTaskExecutionParams execParams, String specificPath, String specificType) in D:\a\certify-internal\certify-internal\src\certify-build\certify-plugins\src\DeploymentTasks\Core\Providers\CertificateExport.cs:line 193

I think I had used this successfully in the past, but I'm not sure. I observed it in version 7.1.0.0 and also after upgrading to 7.1.1.0.

I have deleted the stored password, created a new one, and tried turning the setting off and on multiple times. The error is consistent and 100% reproducible when the setting to encrypt the key with (any) stored password is enabled.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions