##// END OF EJS Templates
Mail Handler: option for specifying a custom CA bundle (#19182)....
Jean-Philippe Lang -
r13907:9e39ad471994
parent child
Show More
@@ -30,6 +30,9 module Net
30 request.basic_auth url.user, url.password if url.user
30 request.basic_auth url.user, url.password if url.user
31 http = new(url.host, url.port)
31 http = new(url.host, url.port)
32 http.use_ssl = (url.scheme == 'https')
32 http.use_ssl = (url.scheme == 'https')
33 if options[:certificate_bundle]
34 http.ca_file = options[:certificate_bundle]
35 end
33 if options[:no_check_certificate]
36 if options[:no_check_certificate]
34 http.verify_mode = OpenSSL::SSL::VERIFY_NONE
37 http.verify_mode = OpenSSL::SSL::VERIFY_NONE
35 end
38 end
@@ -42,7 +45,7 class RedmineMailHandler
42 VERSION = '0.2.3'
45 VERSION = '0.2.3'
43
46
44 attr_accessor :verbose, :issue_attributes, :allow_override, :unknown_user, :default_group, :no_permission_check,
47 attr_accessor :verbose, :issue_attributes, :allow_override, :unknown_user, :default_group, :no_permission_check,
45 :url, :key, :no_check_certificate, :no_account_notice, :no_notification
48 :url, :key, :no_check_certificate, :certificate_bundle, :no_account_notice, :no_notification
46
49
47 def initialize
50 def initialize
48 self.issue_attributes = {}
51 self.issue_attributes = {}
@@ -64,6 +67,7 class RedmineMailHandler
64 "you don't want the key to appear in the command",
67 "you don't want the key to appear in the command",
65 "line)") {|v| read_key_from_file(v)}
68 "line)") {|v| read_key_from_file(v)}
66 opts.on("--no-check-certificate", "do not check server certificate") {self.no_check_certificate = true}
69 opts.on("--no-check-certificate", "do not check server certificate") {self.no_check_certificate = true}
70 opts.on("--certificate-bundle FILE", "certificate bundle to use") {|v| self.certificate_bundle = v}
67 opts.on("-h", "--help", "show this help") {puts opts; exit 1}
71 opts.on("-h", "--help", "show this help") {puts opts; exit 1}
68 opts.on("-v", "--verbose", "show extra information") {self.verbose = true}
72 opts.on("-v", "--verbose", "show extra information") {self.verbose = true}
69 opts.on("-V", "--version", "show version information and exit") {puts VERSION; exit}
73 opts.on("-V", "--version", "show version information and exit") {puts VERSION; exit}
@@ -129,7 +133,7 class RedmineMailHandler
129
133
130 debug "Posting to #{uri}..."
134 debug "Posting to #{uri}..."
131 begin
135 begin
132 response = Net::HTTPS.post_form(URI.parse(uri), data, headers, :no_check_certificate => no_check_certificate)
136 response = Net::HTTPS.post_form(URI.parse(uri), data, headers, :no_check_certificate => no_check_certificate, :certificate_bundle => certificate_bundle)
133 rescue SystemCallError, IOError => e # connection refused, etc.
137 rescue SystemCallError, IOError => e # connection refused, etc.
134 warn "An error occured while contacting your Redmine server: #{e.message}"
138 warn "An error occured while contacting your Redmine server: #{e.message}"
135 return 75 # temporary failure
139 return 75 # temporary failure
General Comments 0
You need to be logged in to leave comments. Login now