Loading

Connect SFTP with SSH Key in B2C Commerce

Publiseringsdato: Apr 29, 2025
Beskrivelse

In various business cases, it may be required to connect to an external SFTP servers in your custom code logic used for B2C Commerce. The information below covers the process to connect to an SFTP server using SSH Keys.

 

Note: This article assumes that the SSH key is already generated correctly and is available to the user.

Løsning

When you generate a SSH key, it is created in pair:

  1. A public key that is copied to the SSH server(s). Anyone with a copy of the public key can encrypt data which can then only be read by the person who holds the corresponding private key. Once an SSH server receives a public key from a user and considers the key trustworthy, the server marks the key as authorized in its authorized_keys file. Such keys are called authorized keys.

  2. A private key that remains (only) with the user. The possession of this key is proof of the user's identity. Only a user in possession of a private key that corresponds to the public key at the server 

    User is required to convert the private key into .p12 format and store it in the Business Manager under Private Key and Certificates.
    For example, this is how to wrap a private key named testing_id_rsa:
    ======================================
    >>openssl req -new -days 3650 -key testing_id_rsa -out testing_id_rsa.csr
    >>openssl x509 -days 3650 -signkey testing_id_rsa -req -in testing_id_rsa.csr -out testing_id_rsa.cer
    >>openssl pkcs12 -export -out testing_id_rsa.p12 -inkey testing_id_rsa -in testing_id_rsa.cer -certfile testing_id_rsa.cer
    ======================================

    Once the SSH key is converted into .p12 format:
    • Log into Business Manager
    • Go to Administration > Operations > Private Key and Certificates
    • Upload the key (only .p12 format will work)
    • Once the key is uploaded, refer the key using the following code where "key_12" is the name of the .p12 key set up in Business Manager:
      var keyRef = new keyRef("key_p12"); 
    • To connect to the SFTP server, you can use the setIdentity method:
      public void setIdentity( dw.crypto.KeyRef keyRef );
Knowledge-artikkelnummer

000395051

 
Laster
Salesforce Help | Article