Chiffrement du certificat : inclus dans le périmètre

  • Rversion finale: Yokohama
  • Mis à jour 30 janv. 2025
  • 2 minutes de lecture
  • L’API CertificateEncryption fournit des méthodes de chiffrement des certificats dans les applications incluses dans le périmètre.

    Utilisez ces méthodes pour générer un hachage pour le certificat, signer des données à l’aide d’une clé privée et générer un code d’authentification de message.

    CertificateEncryption : CertificateEncryption()

    Instancie un objet CertificateEncryption dans une application incluse dans le périmètre.

    Tableau 1. Paramètres
    Nom Type Description
    Néant

    CertificateEncryption : generateMac (clé de chaîne, algorithme de chaîne, données de chaîne)

    Génère le code d’authentification de message (MAC), qui est utilisé pour authentifier un message.

    Tableau 2. Paramètres
    Nom Type Description
    clé Chaîne Clé à utiliser pour signer le message. Doit être codé en Base64.
    algorithme Chaîne Algorithme à utiliser pour générer le MAC : HmacSHA256, HmacSHA1, HmacMD5, etc.
    données Chaîne Données à traiter.
    Tableau 3. Renvoie
    Type Description
    Chaîne MAC au format base64.

    Cet exemple montre comment utiliser un MAC en utilisant sample_key comme données et HmacSHA256 comme algorithme.

    var mac = new CertificateEncryption;
    var key = "sample_key"; 
    key = gs.base64Encode(key);
    mac.generateMac(key, "HmacSHA256", "sample_data");

    CertificateEncryption : getThumbPrint(String, certificateID, String algorithm)

    Génère un hachage (SHA-1, SHA-256, entre autres) pour le certificat à partir du certificat de magasin de confiance.

    Tableau 4. Paramètres
    Nom Type Description
    ID certificat Chaîne Sys_id de l’enregistrement du certificat dans la table Certificat X.509 [sys_certificate].
    algorithme Chaîne Algorithme à utiliser pour créer le hachage, tel que SHA-1, SHA-256, entre autres.
    Tableau 5. Renvoie
    Type Description
    Chaîne Empreinte digitale au format base64.

    Cet exemple montre comment générer l’empreinte (hachage) du certificat AzureAAD.

    //Create a GlideRecord to the certificate table
    var x509GR = new GlideRecord('sys_certificate');
    
    //If there is a certificate of a name of AzureAAD, get the certificate thumbprint
    if(x509GR.get('name', 'AzureAAD')){
    
    //Use the sys_id and algorithm we want to create a thumbprint
    var thumbPrint = CertificateEncryption.getThumbPrint(x509GR.getUniqueValue(), "SHA-1");
    
    //Print the created thumbprint
    gs.print("Thumbprint for " + x509GR.getDisplayValue() + " is " + thumbPrint);
    }

    Sortie :

    V1X+aguDBTZVVbWMGTXxdzJLmaY=

    CertificateEncryption : getThumbPrintFromKeyStore(String certificateID, String alias, String algorithm)

    Génère un hachage (SHA-1, SHA-256, etc.) pour le certificat à partir de l’entrée du magasin de clés.

    Tableau 6. Paramètres
    Nom Type Description
    ID certificat Chaîne Sys_id de l’enregistrement du certificat dans la table Certificat X.509 [sys_certificate].
    alias Chaîne Nom d’alias du certificat.
    algorithme Chaîne Algorithme à utiliser pour créer le hachage, tel que SHA-1, SHA-256, entre autres.
    Tableau 7. Renvoie
    Type Description
    Chaîne Empreinte digitale au format base64.

    CertificateEncryption : sign(String certificateID, String alias, String aliaspassword, String algorithm, String datatosign)

    Signe les données à l’aide de la clé privée et de l’algorithme spécifié.

    Tableau 8. Paramètres
    Nom Type Description
    ID certificat Chaîne sys_id de l’enregistrement du certificat dans la table Certificat X.509 [sys_certificate].
    alias Chaîne Nom de clé privée.
    aliasmot de passe Chaîne Mot de passe de la clé privée.
    algorithme Chaîne Algorithme à utiliser. Doit être l’une des valeurs suivantes :
    • AUCUNavecRSA
    • MD2withRSA
    • MD5withRSA
    • SHA1withRSA
    • SHA224withRSA
    • SHA256withRSA
    • SHA384withRSA
    • SHA512withRSA
    • AUCUNavecDSA
    • SHA1withDSA
    • SHA224withDSA
    • SHA256avecDSA
    • AUCUNavecECDSA
    • SHA1withECDSA
    • SHA224withECDSA
    • SHA256withECDSA
    • SHA384withECDSA
    • SHA512withECDSA
    DataToSign Chaîne Données à signer.
    Tableau 9. Renvoie
    Type Description
    Chaîne Données signées au format base64.
    var ce = new CertificateEncryption;
    ce.sign("recordID", "alias", "password", "SHA1withRSA", "sign this data");