Page 1 of 2

New API error "No API Key provided"

Posted: Wed Sep 14, 2016 10:41 am
by ScottG
I have tried a few things that have surfaced in this forum regarding this topic, but I cannot seem to make it work. I am attaching my ssl.conf and nagiosxi.conf in hopes that someone can tell me why I can't use the API. TYIA.

Re: New API error "No API Key provided"

Posted: Wed Sep 14, 2016 11:17 am
by rkennedy
Could you please show us how you're attempting to access the API?

Also, a tail of your /var/log/httpd/ssl_error_log when you attempt to access it will help as well.

Re: New API error "No API Key provided"

Posted: Wed Sep 14, 2016 12:17 pm
by ScottG
rkennedy wrote:Could you please show us how you're attempting to access the API?

Code: Select all

curl -XGET "https://nagiosxi.uark.edu/nagiosxi/api/v1/objects/servicegroup?apikey=<MYAPIKEY>&pretty=1" -k
rkennedy wrote:Also, a tail of your /var/log/httpd/ssl_error_log when you attempt to access it will help as well.
Nothing appears in that log when I try to access, however I get the following warning when I restart apache:

Code: Select all

AH01909: RSA certificate configured for 127.0.0.1:443 does NOT include an ID which matches the server name

Re: New API error "No API Key provided"

Posted: Wed Sep 14, 2016 2:01 pm
by ScottG
ScottG wrote:

Code: Select all

AH01909: RSA certificate configured for 127.0.0.1:443 does NOT include an ID which matches the server name
I figured out what this error was, by the way. I don't think its relevant.

Re: New API error "No API Key provided"

Posted: Wed Sep 14, 2016 3:24 pm
by mcapra
Can you share the verbose output of that curl?

Code: Select all

curl -XGET "https://nagiosxi.uark.edu/nagiosxi/api/v1/objects/servicegroup?apikey=<MYAPIKEY>&pretty=1" -k -v
Feel free to PM it if you have security concerns.

Have you also tried using/creating a new API key?

Re: New API error "No API Key provided"

Posted: Wed Sep 14, 2016 3:34 pm
by ScottG
mcapra wrote:Can you share the verbose output of that curl?
Here you go:

Code: Select all

$ curl -v -XGET "https://nagiosxi.uark.edu/nagiosxi/api/v1/objects/servicegroup?apikey=<MYAPIKEY>&pretty=1"
* About to connect() to nagiosxi.uark.edu port 443 (#0)
*   Trying 10.7.2.37...
* Connected to nagiosxi.uark.edu (10.7.2.37) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* SSL connection using TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
* Server certificate:
* 	subject: CN=nagiosxi.uark.edu,OU=UITS - IT Services,O=University of Arkansas,STREET=University of Arkansas,L=Fayetteville,ST=AR,postalCode=72701,C=US
* 	start date: Jul 21 00:00:00 2016 GMT
* 	expire date: Jul 21 23:59:59 2018 GMT
* 	common name: nagiosxi.uark.edu
* 	issuer: CN=InCommon RSA Server CA,OU=InCommon,O=Internet2,L=Ann Arbor,ST=MI,C=US
> GET /nagiosxi/api/v1/objects/servicegroup?apikey=<MYAPIKEY>&pretty=1 HTTP/1.1
> User-Agent: curl/7.29.0
> Host: nagiosxi.uark.edu
> Accept: */*
> 
< HTTP/1.1 200 OK
< Date: Wed, 14 Sep 2016 20:26:57 GMT
< Server: Apache/2.4.6 (Red Hat Enterprise Linux) OpenSSL/1.0.1e-fips PHP/5.4.16
< X-Powered-By: PHP/5.4.16
< Access-Control-Allow-Orgin: *
< Access-Control-Allow-Methods: *
< Content-Length: 31
< Content-Type: application/json
< 
* Connection #0 to host nagiosxi.uark.edu left intact
{"error":"No API Key provided"}
mcapra wrote:Have you also tried using/creating a new API key?
I'm trying to figure out how to create new keys now.

Re: New API error "No API Key provided"

Posted: Wed Sep 14, 2016 4:39 pm
by mcapra
There isn't a very good way to "regenerate" a user's API key at the moment. This feature is planned for 5.3.0 though.

Creating a new user, logging in as that user, and clicking the user's name in the top-right corner is a good way to secure a fresh API key.

Re: New API error "No API Key provided"

Posted: Wed Sep 14, 2016 4:52 pm
by ScottG
I used the key for the "nagiosadmin" local account and got the same result.

Re: New API error "No API Key provided"

Posted: Thu Sep 15, 2016 9:32 am
by lmiltchev
What is the Nagios XI version that you are currently using?

Re: New API error "No API Key provided"

Posted: Thu Sep 15, 2016 9:39 am
by ScottG
lmiltchev wrote:What is the Nagios XI version that you are currently using?
5.2.9