2 # https.rb -- SSL/TLS enhancement for HTTPServer
4 # Author: IPR -- Internet Programming with Ruby -- writers
5 # Copyright (c) 2001 GOTOU Yuuzou
6 # Copyright (c) 2002 Internet Programming with Ruby writers. All rights
9 # $IPR: https.rb,v 1.15 2003/07/22 19:20:42 gotoyuzo Exp $
19 attr_reader :cipher, :server_cert, :client_cert
21 alias orig_parse parse
24 if socket.respond_to?(:cert)
25 @server_cert = socket.cert || @config[:SSLCertificate]
26 @client_cert = socket.peer_cert
27 @client_cert_chain = socket.peer_cert_chain
28 @cipher = socket.cipher
33 alias orig_parse_uri parse_uri
35 def parse_uri(str, scheme="https")
37 return orig_parse_uri(str, scheme)
39 return orig_parse_uri(str)
42 alias orig_meta_vars meta_vars
48 meta["SSL_SERVER_CERT"] = @server_cert.to_pem
49 meta["SSL_CLIENT_CERT"] = @client_cert ? @client_cert.to_pem : ""
51 @client_cert_chain.each_with_index{|cert, i|
52 meta["SSL_CLIENT_CERT_CHAIN_#{i}"] = cert.to_pem
55 meta["SSL_CIPHER"] = @cipher[0]
56 meta["SSL_PROTOCOL"] = @cipher[1]
57 meta["SSL_CIPHER_USEKEYSIZE"] = @cipher[2].to_s
58 meta["SSL_CIPHER_ALGKEYSIZE"] = @cipher[3].to_s