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