Edgar,
Si te sirve para validar el certificado y no hacer facturas si este esta vencido. Por otra parte a mi no me gusta ejecutar un archivo .bat con la instrucción de OpenSSL ya que ademas de presentar problemas de permisos en Vista y Windows 7, no es muy *Elegante*. Aqui les comparto la funcion que uso, espero les sirva.
Primero declaras
Código Delphi
[-]
type
TCertInfo=Record
Issuer:String;
Subject:String;
NotBefore:TDateTime;
NotAfter:TDateTime;
ISExpired:Boolean;
IsTrusted:Boolean;
end;
la funcion es:
Código Delphi
[-]
function GetCertInfio(const AFileName:String):TCertInfo;
var
bp: pBIO;
fn: PAnsiChar;
x: pX509;
x509: pX509;
Cert:TX509Certificate;
begin
InitOpenSSL;
Cert:=TX509Certificate.Create;
try
fn := PAnsiChar(ansistring(AFileName));
bp := BIO_new(BIO_s_file());
BIO_read_filename(bp, Pchar(fn));
x := X509_new;
x509 := PEM_read_bio_X509(bp, x, nil, nil);
Cert.fCertificate:=x;
Result.NotBefore:=Cert.NotBefore;
Result.Issuer:=Cert.Issuer;
Result.Subject:=Cert.Subject;
Result.NotBefore:=Cert.NotBefore;
Result.NotAfter:=Cert.NotAfter;
Result.ISExpired:=Cert.IsExpired;
Result.IsTrusted:=Cert.IsExpired;
X509_free(x509);
finally
Cert.Free;
EVP_cleanup;
end;
end;
y la llamas:
Código Delphi
[-]
procedure TForm1.Button2Click(Sender: TObject);
var
CertInfo:TCertInfo;
begin
CertInfo:=GetCertInfio(ExtractFilePath(Application.ExeName)+'aaa010101aaa_CSD_01.cer.pem');
ListBox1.Items.Add(CertInfo.Issuer);
ListBox1.Items.Add(CertInfo.Subject);
ListBox1.Items.Add(DateTimeToStr(CertInfo.NotBefore));
ListBox1.Items.Add(DateTimeToStr(CertInfo.NotAfter));
ListBox1.Items.Add(BoolToStr(CertInfo.ISExpired,True));
ListBox1.Items.Add(BoolToStr(CertInfo.IsTrusted,true));
end;
y veras que obtienes mucha mas información que solo las fechas de inicio/vencimiento
espero que les sirva
Saludos
Morris