Project

General

Profile

Feature #19182 ยป rdm-mailhandler-cacert.patch

Stephane Lapie, 2015-02-25 09:39

View differences:

extra/mail_handler/rdm-mailhandler.rb 2015-02-25 17:28:42.281727147 +0900
30 30
      request.basic_auth url.user, url.password if url.user
31 31
      http = new(url.host, url.port)
32 32
      http.use_ssl = (url.scheme == 'https')
33
      if options[:certificate_bundle]
34
	http.ca_file = options[:certificate_bundle]
35
      end
33 36
      if options[:no_check_certificate]
34 37
        http.verify_mode = OpenSSL::SSL::VERIFY_NONE
35 38
      end
......
42 45
  VERSION = '0.2.3'
43 46

  
44 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 50
  def initialize
48 51
    self.issue_attributes = {}
......
64 67
                                              "you don't want the key to appear in the command",
65 68
                                              "line)") {|v| read_key_from_file(v)}
66 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 71
      opts.on("-h", "--help",                 "show this help") {puts opts; exit 1}
68 72
      opts.on("-v", "--verbose",              "show extra information") {self.verbose = true}
69 73
      opts.on("-V", "--version",              "show version information and exit") {puts VERSION; exit}
......
128 132

  
129 133
    debug "Posting to #{uri}..."
130 134
    begin
131
      response = Net::HTTPS.post_form(URI.parse(uri), data, headers, :no_check_certificate => no_check_certificate)
135
      response = Net::HTTPS.post_form(URI.parse(uri), data, headers, :no_check_certificate => no_check_certificate, :certificate_bundle => certificate_bundle)
132 136
    rescue SystemCallError => e # connection refused, etc.
133 137
      warn "An error occured while contacting your Redmine server: #{e.message}"
134 138
      return 75 # temporary failure
    (1-1/1)