summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/svc_cert.pm29
1 files changed, 25 insertions, 4 deletions
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 = <OUT>;
+ $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})