Created
November 12, 2025 17:57
-
-
Save phatblat/561b65a4f2eba534d169f78291ac128b to your computer and use it in GitHub Desktop.
Test Slack hooks API from Ruby on macOS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| require 'net/http' | |
| require 'openssl' | |
| uri = URI('https://hooks.slack.com') | |
| puts "Ruby OpenSSL version: #{OpenSSL::OPENSSL_VERSION}" | |
| puts "Default cert file: #{OpenSSL::X509::DEFAULT_CERT_FILE}" | |
| puts "Default cert dir: #{OpenSSL::X509::DEFAULT_CERT_DIR}" | |
| puts | |
| # Test 1: What Ruby sees | |
| http = Net::HTTP.new(uri.host, uri.port) | |
| http.use_ssl = true | |
| http.verify_mode = OpenSSL::SSL::VERIFY_PEER | |
| puts "Testing connection with default settings..." | |
| begin | |
| http.start { |h| h.head('/') } | |
| puts "✓ Connection successful!" | |
| rescue OpenSSL::SSL::SSLError => e | |
| puts "✗ Failed: #{e.message}" | |
| puts "\nBacktrace:" | |
| puts e.backtrace.first(5) | |
| end | |
| # Test 2: Disable CRL checking | |
| puts "\n--- Testing without CRL check ---" | |
| http2 = Net::HTTP.new(uri.host, uri.port) | |
| http2.use_ssl = true | |
| http2.verify_mode = OpenSSL::SSL::VERIFY_PEER | |
| http2.ssl_version = :TLSv1_2 | |
| # Ruby doesn't have a direct "disable CRL" flag, but we can try skipping verification | |
| store = OpenSSL::X509::Store.new | |
| store.set_default_paths | |
| store.flags = 0 # Clear all flags including CRL checks | |
| http2.cert_store = store | |
| begin | |
| http2.start { |h| h.head('/') } | |
| puts "✓ Connection successful without CRL!" | |
| rescue OpenSSL::SSL::SSLError => e | |
| puts "✗ Still failed: #{e.message}" | |
| end | |
| # Test 3: Check what certs are available | |
| puts "\n--- Checking certificate store ---" | |
| puts "Files in cert dir:" | |
| if File.directory?(OpenSSL::X509::DEFAULT_CERT_DIR) | |
| Dir.glob("#{OpenSSL::X509::DEFAULT_CERT_DIR}/*").first(10).each do |f| | |
| puts " #{f}" | |
| end | |
| else | |
| puts " Directory doesn't exist!" | |
| end | |
| if File.exist?(OpenSSL::X509::DEFAULT_CERT_FILE) | |
| puts "\nCert file exists: #{OpenSSL::X509::DEFAULT_CERT_FILE}" | |
| puts "Size: #{File.size(OpenSSL::X509::DEFAULT_CERT_FILE)} bytes" | |
| else | |
| puts "\n✗ Cert file doesn't exist: #{OpenSSL::X509::DEFAULT_CERT_FILE}" | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment