1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00

Make building with SSL support optional

This commit is contained in:
Evan Phoenix 2015-09-18 09:43:51 -07:00
parent cddcbe15ee
commit 302954190c
4 changed files with 43 additions and 4 deletions

View file

@ -2,8 +2,12 @@ require 'mkmf'
dir_config("puma_http11")
if %w'crypto libeay32'.find {|crypto| have_library(crypto, 'BIO_read')} and
%w'ssl ssleay32'.find {|ssl| have_library(ssl, 'SSL_CTX_new')}
create_makefile("puma/puma_http11")
unless ENV["DISABLE_SSL"]
if %w'crypto libeay32'.find {|crypto| have_library(crypto, 'BIO_read')} and
%w'ssl ssleay32'.find {|ssl| have_library(ssl, 'SSL_CTX_new')}
have_header "openssl/bio.h"
end
end
create_makefile("puma/puma_http11")

View file

@ -1,6 +1,10 @@
#define RSTRING_NOT_MODIFIED 1
#include <ruby.h>
#include <rubyio.h>
#ifdef HAVE_OPENSSL_BIO_H
#include <openssl/bio.h>
#include <openssl/ssl.h>
#include <openssl/dh.h>
@ -347,6 +351,10 @@ VALUE engine_peercert(VALUE self) {
return rb_cert_buf;
}
VALUE noop(VALUE self) {
return Qnil;
}
void Init_mini_ssl(VALUE puma) {
VALUE mod, eng;
@ -358,6 +366,8 @@ void Init_mini_ssl(VALUE puma) {
mod = rb_define_module_under(puma, "MiniSSL");
eng = rb_define_class_under(mod, "Engine", rb_cObject);
rb_define_singleton_method(mod, "check", noop, 0);
eError = rb_define_class_under(mod, "SSLError", rb_eStandardError);
rb_define_singleton_method(eng, "server", engine_init_server, 1);
@ -371,3 +381,20 @@ void Init_mini_ssl(VALUE puma) {
rb_define_method(eng, "peercert", engine_peercert, 0);
}
#else
VALUE raise_error(VALUE self) {
rb_raise(rb_eStandardError, "SSL not available in this build");
return Qnil;
}
void Init_mini_ssl(VALUE puma) {
VALUE mod, eng;
mod = rb_define_module_under(puma, "MiniSSL");
rb_define_class_under(mod, "SSLError", rb_eStandardError);
rb_define_singleton_method(mod, "check", raise_error, 0);
}
#endif

View file

@ -128,6 +128,8 @@ module Puma
@listeners << [str, io]
when "ssl"
MiniSSL.check
params = Util.parse_query uri.query
require 'puma/minissl'
@ -253,6 +255,8 @@ module Puma
optimize_for_latency=true, backlog=1024)
require 'puma/minissl'
MiniSSL.check
host = host[1..-2] if host[0..0] == '['
s = TCPServer.new(host, port)
if optimize_for_latency
@ -272,6 +276,8 @@ module Puma
def inherited_ssl_listener(fd, ctx)
require 'puma/minissl'
MiniSSL.check
s = TCPServer.for_fd(fd)
ssl = MiniSSL::Server.new(s, ctx)

View file

@ -102,6 +102,8 @@ module Puma
class SSLError < StandardError
# Define this for jruby even though it isn't used.
end
def self.check; end
end
class Context