Results 1 to 1 of 1

Thread: Crypto Key Problem

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2012
    Posts
    886

    Crypto Key Problem

    While updating the TLSCrypto program to use my latest "clsCrypto" & "NewSocket" classes, I ran into an issue that I had a great deal of difficulty resolving. After upgrading, the Server program got an Error &H80090005 - NTE_BAD_DATA on the CryptImportKey call. This call is used to import and decrypt the Session or Pre-Master Key supplied by the client. After struggling to find the source of the problem after all the code changes, I went back to the original program and discovered that it produced the same error.

    The server program gets it's Private key from a Certificate named "localhost.cer". So I deleted the "localhost" Certificate and attempted to create a new one. Makecert.exe told me that the Public & Private keys did not match. The Public/Private key pair is actually stored in the Container File located in a sub-directory of the C:\Users\UserName\AppData\Roaming\Microsoft\Crypto\RSA\ directory. By printing each file to the screen and looking for the Container name, I was able to find the Container file. The date on this file was 10/04/2014, whereas the Certificates were created on 02/26/2014. So I deleted the issuer Certificate "MyCert CA.cer" as well, and recreated both certificates.

    That solved the problem, but it involved a lot of trial & error. I am assuming that a problem occurred with the Container keys on 10/04/2014, and the operating system created new keys. Most of my programs produce a prompt saying that new keys are being created, but I also use the "clsCrypto" class in service programs, and all messages to the screen must be disabled.

    Does anyone know of an easier way to determine a key mismatch? The call error itself (NTE_BAD_DATA) does not supply a great deal of information.

    J.A. Coutts
    Last edited by couttsj; Nov 29th, 2014 at 04:28 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width