Layer7 API Management

Expand all | Collapse all

How to export private key using API call

  • 1.  How to export private key using API call

    Posted 03-16-2019 07:31 PM

    Version: Gateway 9.2 with cr10 patch

     

    The instructions says: 

    PUT 1.0/privateKeys/{id}/export

     

    Is there a xml template example?

     

    I need to input a password and the location to where to store the file.

     

    Thanks



  • 2.  Re: How to export private key using API call

    Posted 03-17-2019 07:01 PM

    example to export portalman private key,

     

    1.

    PUT https://<my gateway>:9443/restman/1.0/privateKeys/00000000000000000000000000000002:portalman/export

     

    content-type: application/xml

     

    request body:
    <l7:PrivateKeyExportContext xmlns:l7="http://ns.l7tech.com/2010/04/gateway-management">
    <l7:Alias>portalman</l7:Alias>
    <l7:Password>1234</l7:Password>
    </l7:PrivateKeyExportContext>

     

    response:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <l7:Item xmlns:l7="http://ns.l7tech.com/2010/04/gateway-management">
        <l7:Name>00000000000000000000000000000002:portalman Export</l7:Name>
        <l7:Id>00000000000000000000000000000002:portalman</l7:Id>
        <l7:Type>PrivateKeyExportResult</l7:Type>
        <l7:TimeStamp>2018-08-01T10:27:08.173+10:00</l7:TimeStamp>
        <l7:Link rel="self" uri="https://lodg17app32.ca.com:9443/restman/1.0/privateKeys/00000000000000000000000000000002:portalman/export"/>
        <l7:Link rel="privateKey" uri="https://lodg17app32.ca.com:9443/restman/1.0/privateKeys/00000000000000000000000000000002:portalman"/>
        <l7:Resource>
            <l7:PrivateKeyExportResult>
                <l7:Pkcs12Data>MIACAQMwgAYJKoZIhvcNAQcBoIAkgASCA+gwgDCABgkqhkiG9w0BBwGggCSABIID6DCCBVkwggVVBgsqhkiG9w0BDAoBAqCCBPowggT2MCgGCiqGSIb3DQEMAQMwGgQUcTQ6nZyZYm4aJTrmKxuFf2nDyl4CAgQABIIEyMifiK1pfspI1MedFKGJhyMnerzLpnWp3qN62IF0dJ40GwpjqyqjTp8no83WXKHiprWWG7VnWhEgE+NZ518svXrGoIuo0uu0FHGo2uYYIMmlqu1pa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BnTX4wkDwV9bH9BEXz1U3uCyFxQF9Y2lTN48JjmFJZlddvKPAPfmRKMcp3AqX8wcmlDPNcTZsIe4cH2NikUsVxMPEf+k1UOVkviyRyBqdOhFD9GeGSw5T+48B62GGwuHWPd99ktU9tH8vNiVpts0bfcNC/gkqFpK2kPHIgs8A6200RF8tOjZBZ47S1wUD2SDOgQrIN6VL6ClQge1SXj2ZroPLTuLnf9KZ0/UHkAiB1gxc4KhZyVqcbel7XJpDAjDZr0phUEggGjtb54kWoRegJ2ivWHZUUc55Q/2iTNVEWF0vAc6tYrPbv5wsHxSAim64CZ1ILGBNMNsTUMwnUKvec68nAviv15w5xmfVqdBlx4mYjbK+7uFzRCVLa5xNl1wsyDNpxR4mJLyiRZeqwYsShqPME1LMN36l7yIDsTpLBNfz3EhVBM/XkBF9moPLzEe7nmfrzl0+iCNrbfQZU0cRYoToq1w1StepFpecRe3UwEvVU3GnLNiDsM2unZAZqoAHjxVtU/Lx37vVpYqlTRQ6vihJEgasO/h9zYuU28mG5663MiWSWieVzQGi+YWhHvoV7hah7vpUPchpUJFO5nH7ENpwGXBkDlGkbYc4Jdpu/T3DzZQFjyaIJFo62LzwKHM7EBqq1GY9fJHf8KPVXKMqkalvoMEkjyal5qDP0VTXgLAc5+ZmW4PdBwImrHvQR/aINizv8c22jl1uG1PG/b+NbRfNOqqMvdBwt6iA4N64n2FyHz9dZMEUJayXHx6EM74n0ayzHZxE8uj+aIO4F3ggiSaPdWpVVEcVcOTS0IHB0AAAAAAAAAAAAAAAAAAAAAAAAwPTAhMAkGBSsOAwIaBQAEFFxYsuKvaG7lXmdZ0VA/VC/fikZKBBQtkDVd3acJroXFzlhrvGIoMQK6GAICBAAAAA==</l7:Pkcs12Data>
            </l7:PrivateKeyExportResult>
        </l7:Resource>
    </l7:Item>

     

     

    2.
    save to p12 file:
    echo <copy and paste l7:Pkcs12Data> | base64 -d > test.p12

     

    3.

    verified by openssl,

     

    openssl pkcs12 -info -in test.p12