Product Documentation

Connecting to the NetScaler Appliance

Sep 08, 2016

The first step towards using NITRO is to establish a session with the NetScaler appliance and then authenticate the session by using the NetScaler administrator's credentials.

You must create an object of the com.citrix.netscaler.nitro.service.nitro_service class by specifying the NetScaler IP (NSIP) address and the protocol to connect to the appliance (HTTP or HTTPS). You then use this object and log on to the appliance by specifying the user name and the password of the NetScaler administrator.

Note:

  • For the python SDK, the package path is of the form nssrc.com.citrix.netscaler...
  • You must have a user account on that appliance. The configuration operations that you perform are limited by the administrative roles assigned to your account.

The following sample code establishes a session with a NetScaler appliance with IP address 10.102.29.60 by using the HTTPS protocol and also sets a session timeout period (in seconds) of 60 minutes.

Java - Sample code to establish session 복사

//Specify the NetScaler appliance IP address and protocol
nitro_service ns_session = new nitro_service("10.102.29.60","https");

//Specify the login credentials
ns_session.login("admin","verysecret",3600);

.NET - Sample code to establish session 복사

//Specify the NetScaler appliance IP address and protocol
nitro_service ns_session = new nitro_service("10.102.29.60","https");

//Specify the login credentials
ns_session.login("admin","verysecret",3600);

Python - Sample code to establish session 복사

#Specify the NetScaler appliance IP address and protocol
ns_session = nitro_service("10.102.29.60","https")

#Specify the login credentials
ns_session.login("admin","verysecret",3600)

Disable SSL Checks

When using HTTPS, you must make sure that the root CA is added to the truststore. By default, NITRO validates the SSL certificate and verifies the hostname. Disable these validations as shown in the following sample codes.

Java - Sample code for disabling SSL checks 복사

ns_session.set_certvalidation(false);
ns_session.set_hostnameverification(false);

.NET - Sample code for disabling SSL checks 복사

ns_session.certvalidation = false; 
ns_session.hostnameverification = false;

Python - Sample code for disabling SSL checks 복사

ns_session.certvalidation = false
ns_session.hostnameverification = false

Some points to note with regards to session timeout for NetScaler 10.5 and later versions:

  • When restricted timeout param is enabled, NITRO, by default, uses the timeout value that is configured for the logged in user. You can customize this value but it must be limited to the value specified for the user. If no value is specified for the user, the default timeout value of 15 minutes is used.
  • When restricted timeout param is not enabled, NITRO uses the default value of 30 minutes as session timeout.