aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar √Čtienne Deparis 2021-04-28 12:46:59 +0200
committerGravatar √Čtienne Deparis 2021-04-28 12:46:59 +0200
commiteb6a54ab82ca2ddb188e18234e6ba08d2ae4a11e (patch)
tree82254bb74698ce8f72c088ba9cf7d6d05c7fe15f
parent97372a5414792e72f2aaf33099f337c8a1653177 (diff)
downloadruby-net-text-eb6a54ab82ca2ddb188e18234e6ba08d2ae4a11e.tar.gz
ruby-net-text-eb6a54ab82ca2ddb188e18234e6ba08d2ae4a11e.tar.xz
ruby-net-text-eb6a54ab82ca2ddb188e18234e6ba08d2ae4a11e.zip
feat: Use SSL verify_certificate_identity instead of custom check
-rw-r--r--lib/net/gemini/ssl.rb5
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/net/gemini/ssl.rb b/lib/net/gemini/ssl.rb
index da47e31..e59bd03 100644
--- a/lib/net/gemini/ssl.rb
+++ b/lib/net/gemini/ssl.rb
@@ -15,9 +15,8 @@ module Gemini
end
def ssl_verify_cb(cert)
- domain = cert.subject.to_s.sub(/^\/CN=/, '')
- return false if domain != @host
- cert_file = File.expand_path("#{@certs_path}/#{domain}.pem")
+ return false unless OpenSSL::SSL.verify_certificate_identity(cert, @host)
+ cert_file = File.expand_path("#{@certs_path}/#{@host}.pem")
return ssl_check_existing(cert, cert_file) if File.exist?(cert_file)
FileUtils.mkdir_p(File.expand_path(@certs_path))
File.open(cert_file, 'wb') { |f| f.print cert.to_pem }