@@ -22,6 +22,7 | |||||
22 | # create: create a user account |
|
22 | # create: create a user account | |
23 | # --no-permission-check disable permission checking when receiving |
|
23 | # --no-permission-check disable permission checking when receiving | |
24 | # the email |
|
24 | # the email | |
|
25 | # --no-check-certificate do not check server certificate | |||
25 | # -h, --help show this help |
|
26 | # -h, --help show this help | |
26 | # -v, --verbose show extra information |
|
27 | # -v, --verbose show extra information | |
27 | # -V, --version show version information and exit |
|
28 | # -V, --version show version information and exit | |
@@ -57,13 +58,16 require 'rdoc/usage' | |||||
57 |
|
58 | |||
58 | module Net |
|
59 | module Net | |
59 | class HTTPS < HTTP |
|
60 | class HTTPS < HTTP | |
60 | def self.post_form(url, params, headers) |
|
61 | def self.post_form(url, params, headers, options={}) | |
61 | request = Post.new(url.path) |
|
62 | request = Post.new(url.path) | |
62 | request.form_data = params |
|
63 | request.form_data = params | |
63 | request.basic_auth url.user, url.password if url.user |
|
64 | request.basic_auth url.user, url.password if url.user | |
64 | request.initialize_http_header(headers) |
|
65 | request.initialize_http_header(headers) | |
65 | http = new(url.host, url.port) |
|
66 | http = new(url.host, url.port) | |
66 | http.use_ssl = (url.scheme == 'https') |
|
67 | http.use_ssl = (url.scheme == 'https') | |
|
68 | if options[:no_check_certificate] | |||
|
69 | http.verify_mode = OpenSSL::SSL::VERIFY_NONE | |||
|
70 | end | |||
67 | http.start {|h| h.request(request) } |
|
71 | http.start {|h| h.request(request) } | |
68 | end |
|
72 | end | |
69 | end |
|
73 | end | |
@@ -72,7 +76,7 end | |||||
72 | class RedmineMailHandler |
|
76 | class RedmineMailHandler | |
73 | VERSION = '0.1' |
|
77 | VERSION = '0.1' | |
74 |
|
78 | |||
75 | attr_accessor :verbose, :issue_attributes, :allow_override, :unknown_user, :no_permission_check, :url, :key |
|
79 | attr_accessor :verbose, :issue_attributes, :allow_override, :unknown_user, :no_permission_check, :url, :key, :no_check_certificate | |
76 |
|
80 | |||
77 | def initialize |
|
81 | def initialize | |
78 | self.issue_attributes = {} |
|
82 | self.issue_attributes = {} | |
@@ -90,7 +94,8 class RedmineMailHandler | |||||
90 | [ '--priority', GetoptLong::REQUIRED_ARGUMENT], |
|
94 | [ '--priority', GetoptLong::REQUIRED_ARGUMENT], | |
91 | [ '--allow-override', '-o', GetoptLong::REQUIRED_ARGUMENT], |
|
95 | [ '--allow-override', '-o', GetoptLong::REQUIRED_ARGUMENT], | |
92 | [ '--unknown-user', GetoptLong::REQUIRED_ARGUMENT], |
|
96 | [ '--unknown-user', GetoptLong::REQUIRED_ARGUMENT], | |
93 | [ '--no-permission-check', GetoptLong::NO_ARGUMENT] |
|
97 | [ '--no-permission-check', GetoptLong::NO_ARGUMENT], | |
|
98 | [ '--no-check-certificate', GetoptLong::NO_ARGUMENT] | |||
94 | ) |
|
99 | ) | |
95 |
|
100 | |||
96 | opts.each do |opt, arg| |
|
101 | opts.each do |opt, arg| | |
@@ -113,6 +118,8 class RedmineMailHandler | |||||
113 | self.unknown_user = arg.dup |
|
118 | self.unknown_user = arg.dup | |
114 | when '--no-permission-check' |
|
119 | when '--no-permission-check' | |
115 | self.no_permission_check = '1' |
|
120 | self.no_permission_check = '1' | |
|
121 | when '--no-check-certificate' | |||
|
122 | self.no_check_certificate = true | |||
116 | end |
|
123 | end | |
117 | end |
|
124 | end | |
118 |
|
125 | |||
@@ -131,7 +138,7 class RedmineMailHandler | |||||
131 | issue_attributes.each { |attr, value| data["issue[#{attr}]"] = value } |
|
138 | issue_attributes.each { |attr, value| data["issue[#{attr}]"] = value } | |
132 |
|
139 | |||
133 | debug "Posting to #{uri}..." |
|
140 | debug "Posting to #{uri}..." | |
134 | response = Net::HTTPS.post_form(URI.parse(uri), data, headers) |
|
141 | response = Net::HTTPS.post_form(URI.parse(uri), data, headers, :no_check_certificate => no_check_certificate) | |
135 | debug "Response received: #{response.code}" |
|
142 | debug "Response received: #{response.code}" | |
136 |
|
143 | |||
137 | case response.code.to_i |
|
144 | case response.code.to_i |
General Comments 0
You need to be logged in to leave comments.
Login now