ECDSA Public Key Mismatch Despite Using Correct Private Key and Certificate

Hello, I’m facing a QR code error with the following details:

{
  type: "ERROR",
  code: "publicKey_QRCODE_INVALID",
  category: "QRCODE_VALIDATION",
  message: "ECDSA Public Key does not match with qr code ECDSA public key",
  status: "ERROR"
}

I generated the CSR and private key using the SDK, then extracted the public key from the private key with the command:

openssl ec -in private_key.pem -pubout -out public_key.pem

After signing and creating the QR code manually, it says the public key doesn’t match. I’m sure I used the correct private key, certificate, and QR code values. Any idea what might be wrong?

Dear @Andrewmilad7

Thank you for reaching out, and welcome to our community.

The error you’re encountering, publicKey_QRCODE_INVALID, suggests that the public key embedded in the QR code doesn’t match the public key from your private key.

Kindly ensure that the public key format used to generate the QR code matches the expected format, If the QR code was generated manually, ensure that it was correctly encoded and inserted and double-check the exact value of the public key that was embedded in the QR code.

we advise you to Re-generate the QR code using the exact public key output to ensure it matches correctly, verify the encoding and format of the public key used in the QR code and cross-check the consistency between your private key, CSR, and certificate.

If you have any further concerns, please don’t hesitate to reach out with our support team via email:

SP email: sp_support@zatca.gov.sa

Thanks & Regards,

1 Like

Hi, If you used SDK then why you are using openssl to extra any key unable to get this point. Secondly how you are generating QR code using SDK or anyother way?

Thank you for your support and response. Can I generate the CSR and private key using OpenSSL, or is it mandatory to use the SDK?

No it is not mandatory.

You can use SDK or Openssl but seems you are trying to use both which is confusing for me atleast. Now there is a difference when you create CSR for simulation and also in Openssl. Have a look at the following topic,

Hello Malik, iam not using both at the same time , iam just extracting the public key to generate a qr code manually as per zatca specification all its required fields works well except the public key always dismatch