I am trying to parse some information from a SSL cert into some variables and would like each line in its own element.
Here is my cert data:
Certificate:
Data:
Version: 3 (0x2)
Serial Number: 3235 (0xca3)
Signature Algorithm: md5WithRSAEncryption
Issuer: C=US, O=GTE Corporation, CN=GTE CyberTrust Root
Validity
Not Before: Oct 22 17:02:00 2002 GMT
Not After : Oct 22 23:59:00 2003 GMT
Subject: C=US, ST=XXXX, L=XXXXX, O=XXXX Inc., OU=Security, CN=
+XXXXXXX.com/emailAddress=XXXX@XXXX.com
Subject Public Key Info:
Public Key Algorithm: rsaEncryption
RSA Public Key: (1024 bit)
Modulus (1024 bit):
...KEY...
Exponent: 65537 (0x10001)
X509v3 extensions:
X509v3 Basic Constraints:
CA:FALSE
X509v3 Key Usage:
Key Encipherment
X509v3 Certificate Policies:
Policy: 1.2.840.113763.1.2.1.4
CPS: http://www.XXXXXX.com/XXX/XXX.html
Signature Algorithm: md5WithRSAEncryption
...KEY...
subject= /C=US/ST=XXXX/L=XXXXX/O=XXXXX Inc./OU=Security/CN=XXXXX
issuer= /C=US/O=GTE Corporation/CN=GTE CyberTrust Root
So anyway, here is what I have:
my $SSL = "/usr/local/bin/sudo /usr/bin/openssl";
local (*FH);
open (FH, "$SSL x509 -inform PEM -text -noout -subject -issuer -i
+n /tmp/expiredcert.crt 2>/dev/null |")
or return;
my ($var1, $var2) = 0;
while (<FH>) {
my @args = split(/[\n\r\l]*/);
$var1 = $args[1];
$var2 = $args[2];
}
close FH;
print " $var1 \n $var2 \n";
=====
Eventually, I want to get the X509v3 Data out of this cert into $varX to put elsewhere.
This was just my starting point to see if this would work.
How do I get the split() to split each element on the end of line? This isnt working the way I anticipated, My output is
s
s