#!/usr/bin/perl use Expect; use IO::Socket; use strict; use warnings; $Expect::Exp_Internal = 1; # for debugging... my $pass = "pa\$\$sphrase\n"; print "$pass"; ############################ # on to the signing portion... ############################ print "\nAttempting to sign $csr to $crt...\n\n"; my $sign_command = system ("openssl x509 -CA CA.crt -CAkey CA.key -req -CAserial CA.srl -req -in $csr -out $crt -days 1825"); my $enter = ("Enter pass phrase for CA.key:"); my $exp = new Expect; $exp->exp_internal(1); $exp->debug(3); $exp->raw_pty(0); $exp->spawn($sign_command) or die "Cannot spawn sign_command.\n"; $exp->match("$enter"); $exp->send ("$pass\r"); $exp->soft_close(); print "\n$csr successfully signed into $crt\n"; #### pa$$phrase Attempting to sign good.csr to good.crt... Signature ok subject=/C=US/ST=State/O=MyCompany LLC/CN=internal.domain.company.com Getting CA Private Key Enter pass phrase for CA_NSO.key: