Skip to content

Commit 6cb9bf6

Browse files
authored
Only output prime information to $stderr if $VERBOSE (#88)
This is currently done even in non-$VERBOSE mode. My guess as to the reason it is done is to give the user the impression that the server is doing something and not frozen, but I still think there should be a way to disable it. If the $VERBOSE flag isn't a good way to do that, let's offer some other way to do that.
1 parent e457003 commit 6cb9bf6

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

lib/webrick/ssl.rb

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -95,18 +95,22 @@ module Utils
9595
# the issuer +cn+ and a +comment+ to be stored in the certificate.
9696

9797
def create_self_signed_cert(bits, cn, comment)
98-
rsa = OpenSSL::PKey::RSA.new(bits){|p, n|
99-
case p
100-
when 0; $stderr.putc "." # BN_generate_prime
101-
when 1; $stderr.putc "+" # BN_generate_prime
102-
when 2; $stderr.putc "*" # searching good prime,
103-
# n = #of try,
104-
# but also data from BN_generate_prime
105-
when 3; $stderr.putc "\n" # found good prime, n==0 - p, n==1 - q,
106-
# but also data from BN_generate_prime
107-
else; $stderr.putc "*" # BN_generate_prime
108-
end
109-
}
98+
rsa = if $VERBOSE
99+
OpenSSL::PKey::RSA.new(bits){|p, n|
100+
case p
101+
when 0; $stderr.putc "." # BN_generate_prime
102+
when 1; $stderr.putc "+" # BN_generate_prime
103+
when 2; $stderr.putc "*" # searching good prime,
104+
# n = #of try,
105+
# but also data from BN_generate_prime
106+
when 3; $stderr.putc "\n" # found good prime, n==0 - p, n==1 - q,
107+
# but also data from BN_generate_prime
108+
else; $stderr.putc "*" # BN_generate_prime
109+
end
110+
}
111+
else
112+
OpenSSL::PKey::RSA.new(bits)
113+
end
110114
cert = OpenSSL::X509::Certificate.new
111115
cert.version = 2
112116
cert.serial = 1

0 commit comments

Comments
 (0)