From: ivan Date: Mon, 8 Nov 2010 07:35:59 +0000 (+0000) Subject: certificates ala communigate, RT#7515 X-Git-Tag: TORRUS_1_0_9~120 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=0c084bd209251525e6441cb2b56c46f4ff788a5f certificates ala communigate, RT#7515 --- diff --git a/FS/FS/svc_cert.pm b/FS/FS/svc_cert.pm index b77ff521d..1d5711310 100644 --- a/FS/FS/svc_cert.pm +++ b/FS/FS/svc_cert.pm @@ -303,9 +303,30 @@ sub generate_csr { $self->csr($csr); } -#sub check_csr { -# my $self = shift; -#} +sub check_csr { + my $self = shift; + + my $in = $self->csr; + + run( [qw( openssl req -subject -noout ), ], + '<'=>\$in, + '>pipe'=>\*OUT, '2>'=>'/dev/null' + ) + ;#or die "error running openssl: $!"; + + #subject=/CN=cn.example.com/ST=AK/O=Tofuy/OU=Soybean dept./C=US/L=Tofutown + my $line = ; + $line =~ /^subject=\/(.*)$/ or return (); + my $subj = $1; + + map { if ( /^\s*(\w+)=\s*(.*)\s*$/ ) { + ($1=>$2); + } else { + (); + } + } + split('/', $subj); +} sub generate_selfsigned { my $self = shift; @@ -360,7 +381,7 @@ sub check_x509 { $hash{$f} = { map { if ( /^\s*(\w+)=\s*(.*)\s*$/ ) { ($1=>$2); } else { - (''=>''); + (); } } split('/', $hash{$f}) diff --git a/httemplate/view/svc_cert.cgi b/httemplate/view/svc_cert.cgi index 48494d2d2..0cd66b422 100644 --- a/httemplate/view/svc_cert.cgi +++ b/httemplate/view/svc_cert.cgi @@ -33,9 +33,31 @@ my @fields = ( { 'field'=>'csr', 'value'=> sub { my $svc_cert = shift; - if ( $svc_cert->csr ) { #display the subject etc? - '
'. "\n". $svc_cert->csr.
-        '
'; + if ( $svc_cert->csr ) { + + my $out = ''; + + my %hash = $svc_cert->check_csr; + + $out .= include('/elements/table-grid.html'). #''. + ''; + + my $col = $svc_cert->subj_col; + + foreach my $key (keys %hash) { + $out .= "". + ""; + } + + $out .= '
'. + 'Requested by
". $labels{$col->{$key}}. "". $hash{$key}. "
'; + + $out .= + '
'. $svc_cert->csr.
+          '
'; + + $out; + } elsif ( $svc_cert->common_name ) { my $svcnum = $svc_cert->svcnum; qq(Generate);