You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

server.rb 610B

12345678910111213141516171819202122232425
  1. module CryptCheck
  2. module Tls
  3. module Smtp
  4. class Server < Tls::TcpServer
  5. attr_reader :domain
  6. def initialize(hostname, family, ip, port, domain:)
  7. @domain = domain
  8. super
  9. end
  10. def ssl_connect(socket, context, method, &block)
  11. socket.recv 1024
  12. socket.write "EHLO #{Socket.gethostbyname(Socket.gethostname).first}\r\n"
  13. features = socket.recv(1024).split "\r\n"
  14. starttls = features.find { |f| /250[- ]STARTTLS/ =~ f }
  15. raise TLSNotAvailableException unless starttls
  16. socket.write "STARTTLS\r\n"
  17. socket.recv 1024
  18. super
  19. end
  20. end
  21. end
  22. end
  23. end