Skip to content

Instantly share code, notes, and snippets.

@kapouer
Created April 10, 2011 15:30
Show Gist options
  • Save kapouer/912440 to your computer and use it in GitHub Desktop.
Save kapouer/912440 to your computer and use it in GitHub Desktop.
Add --no-ssl2 option to disable ssl2 methods
--- a/src/node_crypto.cc
+++ b/src/node_crypto.cc
@@ -98,11 +98,23 @@
String::Utf8Value sslmethod(args[0]->ToString());
if (strcmp(*sslmethod, "SSLv2_method") == 0) {
+#ifndef OPENSSL_NO_SSL2
method = SSLv2_method();
+#else
+ return ThrowException(Exception::Error(String::New("SSLv2 methods disabled")));
+#endif
} else if (strcmp(*sslmethod, "SSLv2_server_method") == 0) {
+#ifndef OPENSSL_NO_SSL2
method = SSLv2_server_method();
+#else
+ return ThrowException(Exception::Error(String::New("SSLv2 methods disabled")));
+#endif
} else if (strcmp(*sslmethod, "SSLv2_client_method") == 0) {
+#ifndef OPENSSL_NO_SSL2
method = SSLv2_client_method();
+#else
+ return ThrowException(Exception::Error(String::New("SSLv2 methods disabled")));
+#endif
} else if (strcmp(*sslmethod, "SSLv3_method") == 0) {
method = SSLv3_method();
} else if (strcmp(*sslmethod, "SSLv3_server_method") == 0) {
--- a/wscript
+++ b/wscript
@@ -143,6 +143,13 @@
, dest='openssl_libpath'
)
+ opt.add_option( '--no-ssl2'
+ , action='store_true'
+ , default=False
+ , help="Disable OpenSSL v2"
+ , dest='openssl_nov2'
+ )
+
opt.add_option( '--oprofile'
, action='store_true'
, default=False
@@ -338,6 +345,9 @@
conf.fatal("Could not autodetect OpenSSL support. " +
"Make sure OpenSSL development packages are installed. " +
"Use configure --without-ssl to disable this message.")
+ # Disable ssl v2 methods
+ if o.openssl_nov2:
+ conf.env.append_value("CPPFLAGS", "-DOPENSSL_NO_SSL2=1")
else:
Options.options.use_openssl = conf.env["USE_OPENSSL"] = False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment