enforce_ssl_verify_true.rb
· 955 B · Ruby
Raw
# Enables existing Email channels to verify SSL certificates
# (MAY break Email communication if certificates are invalid!)
Channel
.where(area: 'Email::Account Email::Notification')
.each do |channel|
['inbound', 'outbound'].each do |dir|
next if ['pop3', 'imap', 'smtp'].exclude?(channel.options.dig(dir, :adapter))
next if !channel.options[dir].key? :options
channel.options[dir][:options][:ssl_verify] = true
end
channel.save!
end
end
# Enable SSL certificate verification for i-doit integration
# (MAY break i-doit functionality if certificates are invalid!)
config = Setting.get('idoit_config')
unless config.blank? do
Setting.set('idoit_config', config.merge('verify_ssl' => true))
end
# Side note: Elasticsearch has an option to verify SSL as well. This might be an edge case.
# By default these certificates are self-signed and thus you may not want to run this at all
Setting.set('es_ssl_verify', true)
| 1 | # Enables existing Email channels to verify SSL certificates |
| 2 | # (MAY break Email communication if certificates are invalid!) |
| 3 | |
| 4 | Channel |
| 5 | .where(area: 'Email::Account Email::Notification') |
| 6 | .each do |channel| |
| 7 | ['inbound', 'outbound'].each do |dir| |
| 8 | next if ['pop3', 'imap', 'smtp'].exclude?(channel.options.dig(dir, :adapter)) |
| 9 | next if !channel.options[dir].key? :options |
| 10 | |
| 11 | channel.options[dir][:options][:ssl_verify] = true |
| 12 | end |
| 13 | channel.save! |
| 14 | end |
| 15 | end |
| 16 | |
| 17 | # Enable SSL certificate verification for i-doit integration |
| 18 | # (MAY break i-doit functionality if certificates are invalid!) |
| 19 | |
| 20 | config = Setting.get('idoit_config') |
| 21 | unless config.blank? do |
| 22 | Setting.set('idoit_config', config.merge('verify_ssl' => true)) |
| 23 | end |
| 24 | |
| 25 | # Side note: Elasticsearch has an option to verify SSL as well. This might be an edge case. |
| 26 | # By default these certificates are self-signed and thus you may not want to run this at all |
| 27 | Setting.set('es_ssl_verify', true) |