- connection = Net::HTTP.start(domain, :use_ssl => true)
- certificate = connection.peer_cert
+ socket = TCPSocket.new(address, 443)
+
+ ssl = OpenSSL::SSL::SSLSocket.new(socket, context)
+ ssl.sync_close = true
+ ssl.hostname = domains.first
+ ssl.connect
+rescue StandardError => e
+ puts "Error connecting to #{host}: #{e.message}"
+end
+
+if ssl
+ certificate = ssl.peer_cert