Closed nomodz4real closed 5 years ago
Hmm - the error looks to be a strong hint here - are you sure your pfsense instance is located at address 192.168.1.1
on port 443
? Perhaps check with curl or a browser first
Ahh, good point, is there a way to specify the port to communicate on?
Edit: I found the way to reference the port when calling PfsenseFauxapi()
I was able to get past the port issue (I believe) by doing the following:
fauxapi_host=sys.argv[1]
fauxapi_apikey=os.getenv('FAUXAPI_APIKEY')
fauxapi_apisecret=os.getenv('FAUXAPI_APISECRET')
fauxapi_port=sys.argv[2]
FauxapiLib = PfsenseFauxapi(fauxapi_host, fauxapi_port, fauxapi_apikey, fauxapi_apisecret, debug=True)
where sys.argv[2] is the port number my pfsense listens on. Having done so I no longer get the timeout but get the following error. Not sure if the way I refer to the port is incorrect or if my pfsense running http with a self signed cert is the issue.
OSError: Could not find a suitable TLS CA certificate bundle, invalid path: 3yU3jutN7X258YpRtsTA13CAKY2NTN872Is02EXqKGz3l27AF4S5XTIQEhRn
Any ideas?
Edit: Unsure why the first code is not formatting correctly, so apologies. also the path is my key so perhaps the port variable 'fauxapi_port' is in the wrong place, gonna try and play around with that.
Looking at the code base I didn't see a way to specify the port so I set my pfsense back to 443 for now, I will raise a separate issue for the port specification parameter capabilities.
The program is able to contact the server with the following code:
FauxapiLib = PfsenseFauxapi(fauxapi_host, fauxapi_apikey, fauxapi_apisecret, debug=True)
But I am now getting an authentication failed message, I made sure to try exporting my environment variables as follows:
export FAUXAPI_APIKEY=PFFAapi
export FAUXAPI_APISECRET=3yU3jutN7X258YpRtsTA13CAKY2NTN872Is02EXqKGz3l27AF4S5XTIQEhRn
Here is the error I receive.
PfsenseFauxapi.PfsenseFauxapi.PfsenseFauxapiException: ('Unable to complete system_stats() request', {'callid': '5cf3049c7b523', 'message': 'authentication failed'})
You should be able to specify the port as part of the host after a :
mark as per standard URL formats - fair enough though, this is not stated in the documentation anywhere so unless it occurs to you it might be difficult to discover it
For example:-
pfsense_address = '192.168.1.1'
pfsense_port = 12345
fauxapi_host = '{}:{}'.format(pfsense_address, pfsense_port)
For the sake of future people reading this thread - there is currently no fauxapi_port
parameter in the pfsense-fauxapi
Python library - https://github.com/ndejong/pfsense_fauxapi_client_python
I'll hold out on #49 for the time being unless there is a major issue I'm not seeing myself.
Thanks for that update, I closed out #49 as your suggestion worked perfectly.
I am going to close this issue out now as my authentication issue was resolved by properly formatting the api key in addition to the secret.
I used
echo PFFA
head /dev/urandom | base64 -w0 | tr -d /+= | head -c 20``
for the key and
echo
head /dev/urandom | base64 -w0 | tr -d /+= | head -c 60``
for the secret per the documentation and am now able to get a response and returns to my calls. Thanks for all the help @ndejong !
Tl;Dr My issue was due to not specifying the correct port and how to do this was shown above and I am now up and running.
I have a simple example that is simply trying to print a config_get() and I get the following error.
Code is below
Checking the system logs even with debug set to true I have no indication the script was even able to reach the firewall and I don't see drops from my machine.
I checked and the time for the pfsense server and my machine are within 60 seconds of each other, let me know if any other info is needed to help with this.