Bug: Fix incorrect certtool being called on macOS/Mac OS X
authoricydoge <icydoge@gmail.com>
Wed, 9 May 2018 18:01:47 +0000 (19:01 +0100)
committericydoge <icydoge@gmail.com>
Wed, 9 May 2018 18:01:47 +0000 (19:01 +0100)
Apple rolls their own certtool on macOS/Mac OS X, which is distinct from
the correct gnutls-certtool from gnutls installed by Homebrew/MacPorts.

lib/leap_cli/commands/cert.rb

index 68fa944..6d96368 100644 (file)
@@ -132,7 +132,11 @@ module LeapCli; module Commands
     long_running do
       if cmd_exists?('certtool')
         log 0, 'Generating DH parameters (takes a long time)...'
-        output = assert_run!('certtool --generate-dh-params --sec-param high')
+        if (/darwin/ =~ RUBY_PLATFORM) != nil
+          output = assert_run!('gnutls-certtool --generate-dh-params --sec-param high')
+        else
+          output = assert_run!('certtool --generate-dh-params --sec-param high')
+        end
         output.sub!(/.*(-----BEGIN DH PARAMETERS-----.*-----END DH PARAMETERS-----).*/m, '\1')
         output << "\n"
         write_file!(:dh_params, output)