From 4ac36b91e278ea259be95b37912f699f12d47f05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Fri, 21 Jun 2019 18:07:42 +0200 Subject: [PATCH] Accept self-signed SSL certificates with airbrake Since some people hosting errbit might be using it as an internal tool with a self signed certificate, we need to patch Airbrake so it accepts these certificates. --- config/initializers/errbit.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/config/initializers/errbit.rb b/config/initializers/errbit.rb index 9e1ba059c..3eb211bcc 100644 --- a/config/initializers/errbit.rb +++ b/config/initializers/errbit.rb @@ -7,3 +7,20 @@ Airbrake.configure do |config| config.ignore_environments = %w[development test] config.ignore_environments += [Rails.env] if Rails.application.secrets.errbit_project_id.blank? end + +if Rails.application.secrets.errbit_self_hosted_ssl.present? + # Patch from: https://mensfeld.pl/2016/05/setting-up-errbit-reporter-airbrake-v5-gem-to-work-with-self-signed-https-certificate/ + module Patches + module Airbrake + module SyncSender + def build_https(uri) + super.tap do |req| + req.verify_mode = OpenSSL::SSL::VERIFY_NONE + end + end + end + end + end + + Airbrake::SyncSender.prepend(::Patches::Airbrake::SyncSender) +end