Layer 7 API Management

Expand all | Collapse all

Create Private Key via RESTMAN API

Jump to Best Answer
  • 1.  Create Private Key via RESTMAN API

    Posted 07-22-2018 02:51 AM

    Hi All,

     

    I tried to create a Provate key for testing purpose but i am getting below error:

     

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <l7:Error xmlns:l7="http://ns.l7tech.com/2010/04/gateway-management">
    <l7:Type>NotAllowed</l7:Type>
    <l7:TimeStamp>2018-07-22T12:20:20.070+05:30</l7:TimeStamp>
    <l7:Link rel="self" uri="https://gateway1.l7tech.com:8443/restman/1.0/privateKeys"/>
    <l7:Detail>HTTP 405 Method Not Allowed</l7:Detail>
    </l7:Error>

     

    I copied the code from  https://<gateway node/cluster name>:8443/restman/1.0/doc/restDoc.html#1.0/privateKeys

    from PrivateKeyCreationContext

     

    Thanks

    Pratyush



  • 2.  Re: Create Private Key via RESTMAN API

    Posted 07-22-2018 07:35 PM

    Dear pratysin ,

    The error is "HTTP 405 Method Not Allowed", the should indicate that you either used wrong http method, or you disabled the http method on restman service(you can double check the allowed http method by right click on restman service -> select Service Properties -> HTTP/FTP tab -> Allowed HTTP Methods).

     

    Regards,

    Mark



  • 3.  Re: Create Private Key via RESTMAN API

    Posted 07-23-2018 01:43 AM

    Thanks for the reply Zhijun.

     

    I checked the above steps and i am already configured it correctly. I feel somewhere i am doing wrong in providing the XML code as POST method. To create a Private Key I am giving the below XML code in my POSTMAN :

     

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <l7:PrivateKeyCreationContext xmlns:l7="http://ns.l7tech.com/2010/04/gateway-management">
    <l7:Name>srcAlias</l7:Name>
    <l7:Type>ResourceAccess</l7:Type>
    <l7:Dn>CN=srcAlias</l7:Dn>
    </l7:PrivateKeyCreationContext>

     

    After giving this I am facing this issue.

     

    Thanks

    Pratyush



  • 4.  Re: Create Private Key via RESTMAN API
    Best Answer

    Posted 07-23-2018 07:29 PM

    Okay, I believe you called the /restman/1.0/privateKeys endpoint, not the /restman/1.0/privateKeys/{id}.

    /restman/1.0/privateKeys only allow GET, when you create new private key, you should POST to /restman/1.0/privateKeys/{id}

    {id} is in the form of [keystore ID]:[alias]

     

    I done a test on gw9.3, the following is working to me,

    method: POST

    content-type: application/xml

    authentication: basic authentication

    URL: https://<gateway:port>/restman/1.0/privateKeys/00000000000000000000000000000002:srcAlias 

    body:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <l7:PrivateKeyCreationContext xmlns:l7="http://ns.l7tech.com/2010/04/gateway-management">
    <l7:Dn>CN=srcAlias</l7:Dn>
    </l7:PrivateKeyCreationContext>

     

    note1: Your sample xml has some elements not recognized, it will cause "bad request" error

    note2: 00000000000000000000000000000002 should be the default keystore ID, you can double confirm by sending a GET request to /restman/1.0/privateKeys

     

    For more details and sample request, please refer to restman help,

    https://<your gateway>:8443/restman/1.0/doc/restDoc.html#1.0/privateKeys