I am running OPNsense 19.1.1 and attempting to access the API via Ruby
This code snippet:
require 'net/http'
require 'openssl'
require 'json'
uri = URI('https://10.15.1.227/api/captiveportal/service/searchtemplates')
request = Net::HTTP::Get.new(uri)
request.basic_auth '123', 'abc'
result = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
http.request(request)
end
puts result.body
produces the error:
SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
I have confirmed that the key and secret are correct.
Am I doing it right?
Thanks
verify_mode NONE doesn't seem to do what you expect.
I've tried with and without http.verify_mode = OpenSSL::SSL::VERIFY_NONE with the same result.
Thanks
This one is for working with legacy pages but I am sure you can adjust it for API as it is simplier:
https://github.com/fabianfrz/scripts/blob/master/OPNsense/backup_over_http.rb#L13-L40
Awesome! That did it. Here's the code that works for any interested...
require 'net/http'
require 'openssl'
require 'json'
uri = URI('https://10.15.1.227/api/captiveportal/service/searchtemplates')
request = Net::HTTP::Get.new(uri)
request.basic_auth '123', 'abc'
result = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true, :verify_mode => OpenSSL::SSL::VERIFY_NONE) do |http|
http.request(request)
end
puts result.body