can anyone help me with some certificate issues..? I'm using Landscape, and trying to use the python API, but I get a CA mismatch, but I've downloaded the .pem, and pointed the script to the location of the .pem.. I get a 403, and error: Message: {"message": "The request signature we calculated does not match the signature you provided. Check your key and signing method.", "error": "SignatureDoesNotMatch"}

Trying to do some testing on a LAN without a CA, the script is being run on the server that Landscape is being run on. Here is the contents of my python script, obviously with critical information changed.

    #!/usr/bin/python
import os, json, sys
from landscape_api.base import API, HTTPError

# change these accordingly
uri = "https://placeholder.bla"
key = "VQ6PP8Vxxxxxx971NHRY"
secret = "RZ+IOK0s8+UQkRWfsxxxxxxxxLhSFKDwIf5Df"
ca = "~/api/key.pem"

api = API(uri, key, secret, ca)
try:
    computers = api.get_computers(query="alert:security-upgrades")
except HTTPError, e:
    print ("\nGot server error:\n"
           "Code: %d\n"
           "Message: %s\n") % (e.code, e.message)
    sys.exit(1)

if len(computers) == 0:
   print "No computers have pending security upgrades."
else:
    for computer in computers:
        print "Id:", computer["id"]
        print "Title:", computer["title"]
        print "Hostname:", computer["hostname"]
        print "Last ping:", computer["last_ping_time"]
        print "Memory:", computer["total_memory"]
        if computer["reboot_required_flag"]:
            print "Needs to reboot!"
        print
share|improve this question
up vote 4 down vote accepted

Make sure your API endpoint URI is exactly as shown in the Landscape server. Typically it will end with /api/ (trailing slash included). And, of course, that the access keys are correct.

share|improve this answer
    
Used the following command to get the cert.. "echo -n | openssl s_client -connect server:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee /home/user/api/key.pem" EDIT: So it was the ending slash.. Wow. I feel stupid. :( Thanks! – Harry Lavender Jan 9 '15 at 12:24

Are you actually using ~/api/key.pem ? You might need to throw in an os.path.expanduser around it, or otherwise provide the full path.

share|improve this answer
    
Changed to the full file path, so /home/user/api/key.pem - No change. :( – Harry Lavender Jan 9 '15 at 12:22

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.