This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git


The following commit(s) were added to refs/heads/master by this push:
     new 457ccd4  Needs more code
457ccd4 is described below

commit 457ccd4ab30142157fcf18e0d7a3ef338311a39a
Author: Sebb <[email protected]>
AuthorDate: Wed Mar 23 15:28:52 2022 +0000

    Needs more code
---
 lib/whimsy/asf/ldap_setup.rb | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/lib/whimsy/asf/ldap_setup.rb b/lib/whimsy/asf/ldap_setup.rb
index 95ff71e..04f3724 100644
--- a/lib/whimsy/asf/ldap_setup.rb
+++ b/lib/whimsy/asf/ldap_setup.rb
@@ -16,13 +16,21 @@ ETCLDAP = case
   else '/etc/ldap'
 end
 
+def extract_cert(host=nil)
+  host ||= HOSTS.sample[%r{//(.*?)(/|$)}, 1]
+  puts ['openssl', 's_client', '-connect', host, '-showcerts'].join(' ')
+  out, _, _ = Open3.capture3 'openssl', 's_client',
+    '-connect', host, '-showcerts'
+  out.scan(/^-+BEGIN.*?\n-+END[^\n]+\n/m).last
+end
+
 def configure
   cert = Dir["#{ETCLDAP}/asf*-ldap-client.pem"].first
 
   # verify/obtain/write the cert
   unless cert
     cert = "#{ETCLDAP}/asf-ldap-client.pem"
-    File.write cert, self.extract_cert
+    File.write cert, extract_cert
   end
 
   # read the current configuration file

Reply via email to