'CertEnrol import pfx The password you entered is incorrect

I'm created pfx certificate using by certEntroll when I imported on windows 10 it's imported successfuly but when i tried on windwos 7 i got an error "The password you entered is incorrect" How do fix it? This is part of code how i create PFX from CA

 var objCertRequest = new CCertRequest();
        var iDisposition = objCertRequest.RetrievePending(requestId, caIP + @"\" + caNAme);

        if (iDisposition == CR_DISP_ISSUED)
        {
            var cert = objCertRequest.GetCertificate(CR_OUT_BASE64 | CR_OUT_CHAIN);
            var objEnroll = new CX509Enrollment();
            objEnroll.Initialize(X509CertificateEnrollmentContext.ContextUser);
            objEnroll.InstallResponse(
                  InstallResponseRestrictionFlags.AllowUntrustedRoot,
                 cert,
                 EncodingType.XCN_CRYPT_STRING_BASE64, password);
            var certResponce = objEnroll.CreatePFX(password, PFXExportOptions.PFXExportChainNoRoot);
        }


Solution 1:[1]

I know this post is a about a year old, but I just had the same error on a similar issue. In my case I had used OpenSSL 3.0.0 to create the .pfx file. I could import the .pfx file on Windows 10, but got an error on Windows Server 2012. OpenSSL apparently uses some default settings that are not supported on older versions of Windows. When I used OpenSSL 1.1.1 it worked fine.

My issue was on Windows Server 2012, but I just tested Windows 7 and it was the same issue there.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 FluffyBike