Archived Forum Post

Index of archived forum posts

Question:

DecryptUsingPfxFile not working anymore

Aug 03 '16 at 02:13

Hi,
We have an issue with mail decryption after updating from ChilkatDotNet2 to ChilkatDotNet4.
We had used Chilkat2 (9.4.1) on Framework 2.0 and all worked fine. Now we upgraded to ChilkatDotNet45 (9.5.0.56) and mime.DecryptUsingPfxFile() does not work anymore.
Same code on the same email and the same certificate, different results.

Having Verbose logging switched on below is all I get on 9.5.0.56:

ChilkatLog:
  DecryptUsingPfxFile:
    DllDate: Mar 11 2016
    ChilkatVersion: 9.5.0.56
    UnlockPrefix: UPSDEUSMIME
    Username: WKSP000587B3:kln1avp
    Architecture: Little Endian; 32-bit
    Language: .NET 4.5
    VerboseLogging: 1
    pfxPath: D:\UPSDATA\BOSS\DAT\NLCerts\bpUPS.pfx
    Failed.
  --DecryptUsingPfxFile
--ChilkatLog.

When using ChilkatDotNet2.dll in version 9.4.1 I have a success on the decrypt and the following Log content:

ChilkatLog:
  DecryptUsingPfxFile:
    DllDate: Jul  8 2013
    ChilkatVersion: 9.4.1.25
    UnlockPrefix: UPSDEUSMIME
    Username: WKSP000587B3:kln1avp
    Architecture: Little Endian; 32-bit
    Language: .NET 2.0
    VerboseLogging: 1
    pfxFilename: D:\UPSDATA\BOSS\DAT\NLCerts\bpUPS.pfx
    importPfxData:
      ParsePkcs12:
        verifyHmacIntegrity:
          saltNumBytes: 20
          saltBase64: dSkUqts5Cr7UlgDRqw1qVvctt0M=
          numIterations: 2000
          macHashOid: 1.3.14.3.2.26
          macStoredDigest: 874B 3C9E 4DD8 3896 B4F7 EB82 004D D1F3
9913 0C4A
          Password and HMAC verified.
        --verifyHmacIntegrity
        SEQUENCE
        DecodeAsnConstructed:
          Integer
          intBytes: 03
          SEQUENCE
          DecodeAsnConstructed:
            Oid: 1.2.840.113549.1.7.1 (PKCS7 Data)
            Tag=Constructed
            DecodeAsnConstructed:
              OctetString: 1863
              qp_string: 0=82=07C0=82=03=BC=06  *=86H=86=F7=0D=01=07=01=A0=82=03=AD=04=82=03=A90=82=
=03=A50=82=03=A1=06=0B*=86H=86=F7=0D=01=0C=0A=01=02=A0=82=02=B60=82=02=B20=
=1C=06=0A*=86H=86=F7=0D=01=0C=01=030=0E=04=08=B2=FE=9E=9E=AC=E1
            --DecodeAsnConstructed
          --DecodeAsnConstructed
          SEQUENCE
          DecodeAsnConstructed:
            SEQUENCE
            DecodeAsnConstructed:
              SEQUENCE
              DecodeAsnConstructed:
                Oid: 1.3.14.3.2.26
              --DecodeAsnConstructed
              OctetString: 20
              qp_string: =87K<=9EM=D88=96=B4=F7=EB=82=00M=D1=F3=99=13=0CJ
            --DecodeAsnConstructed
            OctetString: 20
            qp_string: u)=14=AA=DB9=0A=BE=D4=96=00=D1=AB=0DjV=F7-=B7C
            Integer
            intBytes: 07D0
          --DecodeAsnConstructed
        --DecodeAsnConstructed
        AuthenticatedSafe:
          SEQUENCE
          DecodeAsnConstructed:
            SEQUENCE
            DecodeAsnConstructed:
              Oid: 1.2.840.113549.1.7.1 (PKCS7 Data)
              Tag=Constructed
              DecodeAsnConstructed:
                OctetString: 937
                qp_string: 0=82=03=A50=82=03=A1=06=0B*=86H=86=F7=0D=01=0C=0A=01=02=A0=82=02=B60=82=02=
=B20=1C=06=0A*=86H=86=F7=0D=01=0C=01=030=0E=04=08=B2=FE=9E=9E=AC=E1@=8D=02=
=02=07=D0=04=82=02=90=87=FEc=A8=C6=C6=DE*=A4=E5(=8B &=84k=99
              --DecodeAsnConstructed
            --DecodeAsnConstructed
            SEQUENCE
            DecodeAsnConstructed:
              Oid: 1.2.840.113549.1.7.6 (PKCS7 EncryptedData)
              Tag=Constructed
              DecodeAsnConstructed:
                SEQUENCE
                DecodeAsnConstructed:
                  Integer
                  intBytes: 00
                  SEQUENCE
                  DecodeAsnConstructed:
                    Oid: 1.2.840.113549.1.7.1 (PKCS7 Data)
                    SEQUENCE
                    DecodeAsnConstructed:
                      Oid: 1.2.840.113549.1.12.1.6 (PKCS12 SafeContentsBag)
                      SEQUENCE
                      DecodeAsnConstructed:
                        OctetString: 8
                        qp_string: J~y1*=9CN=EC
                        Integer
                        intBytes: 07D0
                      --DecodeAsnConstructed
                    --DecodeAsnConstructed
                  --DecodeAsnConstructed
                --DecodeAsnConstructed
              --DecodeAsnConstructed
            --DecodeAsnConstructed
          --DecodeAsnConstructed
        --AuthenticatedSafe
        nContentInfos: 2
        ContentInfo:
          Pkcs7_loadXml:
            PKCS7 Data
            dataSize: 937
          --Pkcs7_loadXml
          PKCS7_DATA
          SafeContents:
            SafeBagOid: 1.2.840.113549.1.12.10.1.2
            Pkcs8ShroudedKeyBag
            Pkcs8ShroudedKeyBag:
              PBE encryption.
              Salt: sv6enqzhQI0=
              Iterations: 2000
              numEncryptedBytes: 656
              algorithm: des
              keyLength: 192
              outputSize: 649
            --Pkcs8ShroudedKeyBag
          --SafeContents
          ContentInfo:
            Pkcs7_loadXml:
              Pkcs7_EncryptedData:
                AlgorithmIdentifier:
                  oid: 1.2.840.113549.1.12.1.6
                  PBE encryption.
                  Salt: Sn55MSqcTuw=
                  Iterations: 2000
                --AlgorithmIdentifier
                numEncryptedBytes: 824
                algorithm: rc2
                keyLength: 40
                outputSize: 817
              --Pkcs7_EncryptedData
            --Pkcs7_loadXml
            PKCS7_ENCRYPTED_DATA
            SafeContents:
              SafeBagOid: 1.2.840.113549.1.12.10.1.3
              CertBag
              x509_cert_E: ups@douane.lan
              x509_cert_DN: C=NL, O=UPS, OU=UPS, E=ups@douane.lan
              x509_serial: 00
              SubjectKeyIdentifier: iyu179VlVBpz7HjVmzV4TAMr6Ck=

            --SafeContents
          --ContentInfo
        --ContentInfo
        numCerts: 1
        importX509_1:
          x509_cert_dn: C=NL, O=UPS, OU=UPS, E=ups@douane.lan
          numPrivateKeys: 1
          Got encrypted private key.
          hashCert_1:
            hashCert:
              CommonName: 
              ValidFrom: Sun, 18 Sep 2015 09:45:24 GMT
              ValidTo: Sun, 16 Sep 2020 09:45:24 GMT
              certHashEntry: 00:
              certHashEntry2: SubjectKeyId:iyu179VlVBpz7HjVmzV4TAMr6Ck=
              This certificate has a private key.
              privKeyHashEntry: 00:
              privKeyHashEntry2: SubjectKeyId:iyu179VlVBpz7HjVmzV4TAMr6Ck=
            --hashCert
          --hashCert_1
        --importX509_1
        PFX imported successfully.
      --ParsePkcs12
      loadPkcs7Der_4:
        DerParseTimeMs: Elapsed time: 0 millisec
        loadPkcs7Xml:
          Pkcs7_loadXml:
            Pkcs7_EnvelopedData:
              RC2_CBC
              IV: wUkqzVT/tV8=
              KeyLength: 40
              numRecipients: 1
              RecipientInfo:
                IssuerAndSerialNumber:
                  serialNumber1: 00
                  issuerCommonName: 
                  issuerCountry: NL
                  issuerState: 
                  issuerLocality: 
                  issuerOrganization: UPS
                --IssuerAndSerialNumber
                encryptedKeyNumBytes: 128
              --RecipientInfo
            --Pkcs7_EnvelopedData
          --Pkcs7_loadXml
        --loadPkcs7Xml
        Pkcs7XmlLoadTimeMs: Elapsed time: 0 millisec
      --loadPkcs7Der_4
      unEnvelope1:
        UnEnvelope:
          FindMatchingPrivateKey:
            NumRecipientInfos: 1
            findPrivateKey: 00:
            Key found!
            RecipientCertSerialNum: 00
            RecipientCertIssuerCN: 
            Found matching private key
            findCert: 00:
          --FindMatchingPrivateKey
          AlgorithmIdentifier:
            oid: 1.2.840.113549.1.1.1
          --AlgorithmIdentifier
          Decrypting symmetric key...(2)
          ModulusLen: 129
          DLen: 128
          PLen: 65
          QLen: 65
          DPLen: 65
          DQLen: 64
          InvQLen: 64
          modulus_bitlen: 1024
          littleEndian: 1
          encryptedData: 4161 B72C 601E D566 E0A9 84D6 DE1E 4C1D
C28D 2EDD EE03 3E71 BDEA 4A17 8055 2F71
E2C9 355E 2AB1 9A88 4BEC 596C 1775 D336
76CA 2962 90F7 2796 2E97 A79B E1D2 AFC8
6943 AD4C 9F7D 475C 9D44 B89A C993 8E13
8300 A2B7 BF80 3A09 7796 3583 ED81 2D5A
E0F2 7326 D082 66F7 F66A 4369 6A07 C271
7740 7DAD 6D23 7A04 1032 90E2 B433 06B5
          exptmod: Elapsed time: 0 millisec
          exptmod_decoded: 029F F94A F31B 5A5D 609D E1D5 C6D5 ECAF
3FE1 F763 D8EE C44C 5963 91AB 706F DF3A
A146 D770 3921 E441 9D38 AD3F 65D2 8B24
B7BF 337B 109B 8AC7 25CE 6235 6C74 7E14
D3EB 6277 4397 0C25 6AAF D4C1 F9A0 CE6D
064B 3CC9 453C 6B2E 45BF 9B8E 1956 380A
4679 D61B 1885 B31A 9901 045B FA95 A4A5
E3E8 BD5F CE8A A3F0 2400 252A B34E E4
          exptmod_decoded_size: 127
          padding: PKCS 1.5
          sizeAfterPkcs15_decode: 5
          Decrypting data using symmetric key (2)
          decryptedSymmetricKeyLen2: 5
          symmetricDecrypt_2:
            setByAlgorithmIdentifier:
              algId_oid: 1.2.840.113549.3.2
              RC2_CBC
              keyLength: 40
            --setByAlgorithmIdentifier
            symmetricKeySizeInBytes: 5
            numBytesToDecrypt: 2840
            algorithm: rc2
            keyLength: 40
            outputSize: 2833
            symmetricDecryptOutputSize: 2833
          --symmetricDecrypt_2
        --UnEnvelope
      --unEnvelope1
      LoadMimeComplete2:
        Found end-of-header.
        setHeaderContents:
          ParseMimeHeader:
            Header is entirely 7-bit
            FinalCodePageDecision: 0
            unfoldedHeaderField1: Mime-Version: 1.0
            MimeField:
              rawField: Mime-Version: 1.0
              name: Mime-Version
              value: 1.0
            --MimeField
            unfoldedHeaderField1: Content-Type: application/x-pkcs7-mime; smime-type=signed-data;    name=smime.p7m
            MimeField:
              rawField: Content-Type: application/x-pkcs7-mime; smime-type=signed-data;    name=smime.p7m
              name: Content-Type
              value: application/x-pkcs7-mime; smime-type=signed-data;    name=smime.p7m
            --MimeField
            unfoldedHeaderField1: Content-Transfer-Encoding: base64
            MimeField:
              rawField: Content-Transfer-Encoding: base64
              name: Content-Transfer-Encoding
              value: base64
            --MimeField
            unfoldedHeaderField2: Content-Disposition: attachment; filename=212VYTVA.DAT
            MimeField:
              rawField: Content-Disposition: attachment; filename=212VYTVA.DAT
              name: Content-Disposition
              value: attachment; filename=212VYTVA.DAT
            --MimeField
          --ParseMimeHeader
        --setHeaderContents
        parseMimeBody:
          contentType: application/x-pkcs7-mime; smime-type=signed-data;    name=smime.p7m
          charset: 
          clearing charset based on content-type.
          treating body as binary (non-character) data.
          treating body as binary data because of attachment status.
          bIsAttachment: 1
          setMimeBodyByEncoding2:
            encoding: base64
            entireBodyLen: 2636
            charset: 
            isText: 0
            wasReally1252: 0
          --setMimeBodyByEncoding2
        --parseMimeBody
      --LoadMimeComplete2
      SEQUENCE
      DecodeAsnConstructed:
        SEQUENCE
        DecodeAsnConstructed:
          Tag=Constructed
          DecodeAsnConstructed:
            Integer
            intBytes: 02
          --DecodeAsnConstructed
          Integer
          intBytes: 00
          SEQUENCE
          DecodeAsnConstructed:
            Oid: 1.2.840.113549.1.1.5
            Null
          --DecodeAsnConstructed
          SEQUENCE
          DecodeAsnConstructed:
            SET
            DecodeAsnConstructed:
              SEQUENCE
              DecodeAsnConstructed:
                Oid: 2.5.4.6
                Printable String
                qp_string: NL
              --DecodeAsnConstructed
            --DecodeAsnConstructed
            SET
            DecodeAsnConstructed:
              SEQUENCE
              DecodeAsnConstructed:
                Oid: 2.5.4.10
                Printable String
                qp_string: UPS
              --DecodeAsnConstructed
            --DecodeAsnConstructed
            SET
            DecodeAsnConstructed:
              SEQUENCE
              DecodeAsnConstructed:
                Oid: 2.5.4.11
                Printable String
                qp_string: UPS
              --DecodeAsnConstructed
            --DecodeAsnConstructed
            SET
            DecodeAsnConstructed:
              SEQUENCE
              DecodeAsnConstructed:
                Oid: 1.2.840.113549.1.9.1 (PKCS9 Signature Attribute)
                IA5 String
                qp_string: ups@douane.lan
              --DecodeAsnConstructed
            --DecodeAsnConstructed
          --DecodeAsnConstructed
          SEQUENCE
          DecodeAsnConstructed:
            UTC String
            qp_string: 150918094524Z
            UTC String
            qp_string: 200916094524Z
          --DecodeAsnConstructed
          SEQUENCE
          DecodeAsnConstructed:
            SET
            DecodeAsnConstructed:
              SEQUENCE
              DecodeAsnConstructed:
                Oid: 2.5.4.6
                Printable String
                qp_string: NL
              --DecodeAsnConstructed
            --DecodeAsnConstructed
            SET
            DecodeAsnConstructed:
              SEQUENCE
              DecodeAsnConstructed:
                Oid: 2.5.4.10
                Printable String
                qp_string: UPS
              --DecodeAsnConstructed
            --DecodeAsnConstructed
            SET
            DecodeAsnConstructed:
              SEQUENCE
              DecodeAsnConstructed:
                Oid: 2.5.4.11
                Printable String
                qp_string: UPS
              --DecodeAsnConstructed
            --DecodeAsnConstructed
            SET
            DecodeAsnConstructed:
              SEQUENCE
              DecodeAsnConstructed:
                Oid: 1.2.840.113549.1.9.1 (PKCS9 Signature Attribute)
                IA5 String
                qp_string: ups@douane.lan
              --DecodeAsnConstructed
            --DecodeAsnConstructed
          --DecodeAsnConstructed
          SEQUENCE
          DecodeAsnConstructed:
            SEQUENCE
            DecodeAsnConstructed:
              Oid: 1.2.840.113549.1.1.1
              Null
            --DecodeAsnConstructed
            Bit String
          --DecodeAsnConstructed
          Tag=Constructed
          DecodeAsnConstructed:
            SEQUENCE
            DecodeAsnConstructed:
              SEQUENCE
              DecodeAsnConstructed:
                Oid: 2.5.29.14
                OctetString: 22
                qp_string: =04=14=8B+=B5=EF=D5eT=1As=ECx=D5=9B5xL=03+=E8)
              --DecodeAsnConstructed
              SEQUENCE
              DecodeAsnConstructed:
                Oid: 2.5.29.35
                OctetString: 105
                qp_string: 0g=80=14=8B+=B5=EF=D5eT=1As=ECx=D5=9B5xL=03+=E8)=A1L=A4J0H1=0B0  =06=03U=04=
=06=13=02NL1=0C0=0A=06=03U=04=0A=13=03UPS1=0C0=0A=06=03U=04=0B=13=03UPS1=1D=
0=1B=06 *=86H
              --DecodeAsnConstructed
              SEQUENCE
              DecodeAsnConstructed:
                Oid: 2.5.29.19
                OctetString: 5
                qp_string: 0=03=01=01=FF
              --DecodeAsnConstructed
            --DecodeAsnConstructed
          --DecodeAsnConstructed
        --DecodeAsnConstructed
        SEQUENCE
        DecodeAsnConstructed:
          Oid: 1.2.840.113549.1.1.5
          Null
        --DecodeAsnConstructed
        Bit String
      --DecodeAsnConstructed
      Success.
    --importPfxData
  --DecryptUsingPfxFile
--ChilkatLog