SalesforceCommerceCloud / b2c-crm-sync

... a contemporary perspective on how to integrate B2C Commerce and the Salesforce Customer 360 Platform to power frictionless customer experiences in the B2C domain.
https://salesforcecommercecloud.github.io/b2c-crm-sync/
BSD 3-Clause "New" or "Revised" License
65 stars 45 forks source link

[BUG] Unable to get public key from key store file #189

Open dmk2861995 opened 1 year ago

dmk2861995 commented 1 year ago

Describe the bug I am getting errors while trying to get the public key using the "npm run crm-sync:sf:cert:publickey:get" command.

Error Details:

Error Message: StackTrace: START

Error: Something went wrong with algorithm 1.2.840.113549.1.1.1. For more details see 'error.context' at Function.parseKey (D:\b2c-crm-sync\node_modules\jks-js\lib\encryption\PKCS8Key.js:40:18) at KeyProtector.recover (D:\b2c-crm-sync\node_modules\jks-js\lib\encryption\KeyProtector.js:106:19) at decrypt (D:\b2c-crm-sync\node_modules\jks-js\lib\index.js:20:19) at D:\b2c-crm-sync\node_modules\jks-js\lib\index.js:56:11 at Array.reduce () at jksToPem (D:\b2c-crm-sync\node_modules\jks-js\lib\index.js:45:17) at Object.toPem (D:\b2c-crm-sync\node_modules\jks-js\lib\index.js:67:10) at Command. (D:\b2c-crm-sync\lib\cli-interface_sfCertPublicKeyGet.js:127:38) at processTicksAndRejections (node:internal/process/task_queues:93:5)

Error Message: StackTrace: END

To Reproduce Steps to reproduce the behavior:

  1. Try to setup B2C-CRM-SYNC using either scratch org or sandbox
  2. Create a self-signed certificate with the same name as the b2cinstance name in salesforce org (scratch org/ sandbox)
  3. Export it as Keystore file and keep it _jwt/sfdc folder
  4. Run "npm run crm-sync:sf:cert:publickey:get" command to get the public key and you will be able see the above error

Expected behavior Able to get keys without any error

Screenshots If applicable, add screenshots to help explain your problem. Certificate and Key Management _ Salesforce image image

Your local environment details:

Your remote environment details:

Additional context I tried the below command to get pkcs12 and tried to get the public key using the same command then it worked but unable to authenticate against AM Command: keytool -importkeystore -srckeystore 00D7d000008qWMS.jks -destkeystore 00D7d000008qWMS.jks -deststoretype pkcs12 Steps I followed:

  1. Get the .jks file
  2. Pass it to "keytool -importkeystore -srckeystore 00D7d000008qWMS.jks -destkeystore 00D7d000008qWMS.jks -deststoretype pkcs12" to get pck12 format
  3. keep the file in "_jwt/sfdc" folder
  4. Run "npm run crm-sync:sf:cert:publickey:get" command to get keys
  5. update the certificate in AM
  6. try to get authenticated using "npm run crm-sync:b2c:auth:jwt". It will throw error
Rvgadr8686 commented 1 year ago

@dmk2861995 Any fix for this? I am also getting the same issue.