Add ssl_verify config option to fix certificate errors

Raw OpenSSL sockets don't find the system CA bundle the same way Net::HTTP
does. ssl_verify (default: true) is now a config setting that applies to
both HTTP REST calls and WebSocket connections. Set via `portainer-cli configure`.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-22 13:07:07 +01:00
parent a1015366a9
commit c59deca51e
6 changed files with 20 additions and 12 deletions
+9 -7
View File
@@ -8,7 +8,7 @@ module PortainerCli
CONFIG_DIR = File.expand_path('~/.portainer-cli').freeze
CONFIG_FILE = File.join(CONFIG_DIR, 'config.yml').freeze
attr_accessor :url, :token, :api_key
attr_accessor :url, :token, :api_key, :ssl_verify
def self.load
new.tap(&:read)
@@ -18,17 +18,19 @@ module PortainerCli
return unless File.exist?(CONFIG_FILE)
data = YAML.safe_load(File.read(CONFIG_FILE), permitted_classes: [], symbolize_names: false) || {}
@url = data['url']
@token = data['token']
@api_key = data['api_key']
@url = data['url']
@token = data['token']
@api_key = data['api_key']
@ssl_verify = data.fetch('ssl_verify', true)
end
def save
FileUtils.mkdir_p(CONFIG_DIR)
data = {}
data['url'] = @url if @url
data['token'] = @token if @token
data['api_key'] = @api_key if @api_key
data['url'] = @url if @url
data['token'] = @token if @token
data['api_key'] = @api_key if @api_key
data['ssl_verify'] = @ssl_verify unless @ssl_verify.nil?
File.write(CONFIG_FILE, YAML.dump(data))
File.chmod(0o600, CONFIG_FILE)
end