Jump to content
Welcome to our new Citrix community!

NITRO to login and grab a session cookie.


Abhijit Das

Recommended Posts

Can anyone provide me a working example of grabbing a session cookie first and then using the session cookie to post. Right now i am using credentials to login everytime to collect stats.

 

I tried this but i get an error:

 

# curl -X POST -s -i -k -H "Content-Type:application/vnd.com.citrix.netscaler.login+json" --basic -u ‘$user:$password' https://<netscaler_management_SNIP>/nitro/v1/config/login/

HTTP/1.1 400 Bad Request

Date: Wed, 12 Jun 2019 23:44:08 GMT

Server: Apache

Set-Cookie: SESSID=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/

Expires: Thu, 19 Nov 1981 08:52:00 GMT

Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0

Pragma: no-cache

Content-Length: 94

Connection: close

Content-Type: application/json; charset=utf-8

Link to comment
Share on other sites

Hello ,

 

Instead of using username and password you can simply pass the Authorization header:

 

Use the below mentioned command in shell to get the base64 output of username and password:

 

root@ns# echo -n nsroot:citrix| b64encode  -m  - | sed -n '2p'

 

In place of citrix above use the nsroot password that you have.

 

Example output:
bnNyb290OmNpdHJpeA=

 

Once you get the output use that in below mentioned command:

 

curl -X GET -H "Authorization: Basic bnNyb290OmNpdHJpeA=" http://<Management_IP>/nitro/v1/stat/sslvserver

 

You should see output as mentioned below after running the curl command:

 

curl -X GET -H "Authorization: Basic bnNyb290OmNpdHJpeA=" http://<Management_IP>/nitro/v1/stat/sslvserver

 

{ "errorcode": 0, "message": "Done", "severity": "NONE", "sslvserver": [ { "vservername": "dummy_lb", "vslbhealth": "100", "primaryipaddress": "0.0.0.0", "primaryport": 0, "type": "SSL", "state": "Unknown", "actsvcs": "1", "ssltotclientauthsuccess": "0", "sslclientauthsuccessrate": 0, "ssltotclientauthfailure": "0", "sslclientauthfailurerate": 0, "sslctxtotencbytes": "0", "sslctxencbytesrate": 0, "sslctxtotdecbytes": "0", "sslctxdecbytesrate": 0, "sslctxtothwencbytes": "0", "sslctxhwencbytesrate": 0, "sslctxtothwdec_bytes": "0", "sslctxhwdec_bytesrate": 0, "sslctxtotsessionnew": "0", "sslctxsessionnewrate": 0, "sslctxtotsessionhits": "0", "sslctxsessionhitsrate": 0 }, { "vservername": "authvs", "vslbhealth": "0", "primaryipaddress": "0", "primaryport": 0, "type": "SSL", "state": "Unknown", "actsvcs": "0", "ssltotclientauthsuccess": "0", "sslclientauthsuccessrate": 0, "ssltotclientauthfailure": "0", "sslclientauthfailurerate": 0, "sslctxtotencbytes": "1304426", "sslctxencbytesrate": 186346, "sslctxtotdecbytes": "3891", "sslctxdecbytesrate": 555, "sslctxtothwencbytes": "0", "sslctxhwencbytesrate": 0, "sslctxtothwdec_bytes": "0", "sslctxhwdec_bytesrate": 0, "sslctxtotsessionnew": "6", "sslctxsessionnewrate": 0, "sslctxtotsessionhits": "0", "sslctxsessionhitsrate": 0 }, { "vservername": "Oauth", "vslbhealth": "0", "primaryipaddress": "0.0.0.0", "primaryport": 0, "type": "SSL", "state": "Unknown", "actsvcs": "0", "ssltotclientauthsuccess": "0", "sslclientauthsuccessrate": 0, "ssltotclientauthfailure": "0", "sslclientauthfailurerate": 0, "sslctxtotencbytes": "0", "sslctxencbytesrate": 0, "sslctxtotdecbytes": "0", "sslctxdecbytesrate": 0, "sslctxtothwencbytes": "0", "sslctxhwencbytesrate": 0, "sslctxtothwdec_bytes": "0", "sslctxhwdec_bytesrate": 0, "sslctxtotsessionnew": "0", "sslctxsessionnewrate": 0, "sslctxtotsessionhits": "0", }

 

Regards,

Saurabh
 

Link to comment
Share on other sites

  • 2 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...