Page 1 of 1
No me funciona shellexecute. Saber caducidad certificado digital
Posted: Tue Mar 11, 2025 4:34 pm
by Garbi
Hola a todos,
Estoy probando esta sentencia para saber la fecha de caducidad de un certificado digital
..\openssl\bin\openssl.exe x509 -in ..\dbf\certificado.pem -noout -enddate >..\dbf\fecha.txt
Si lo ejecuto desde comando me funciona y me crea el fichero fecha.txt, que aunque no lo pone claro se puede obtener la fecha de caducidad del certificado digital :certificado.pem
Pero al ejecutarlo en aplicación he probado :
Code: Select all | Expand
shellexecute(0,"runas","..\openssl\bin\openssl x509 -in ..\dbf\certificado.pem -noout -enddate >..\dbf\fecha.txt","","",1)
Pero no me crea el fichero fecha.txt que desde el comando si me crea.
¿Alguna sugerencia?
Gracias
Re: No me funciona shellexecute. Saber caducidad certificado digital
Posted: Tue Mar 11, 2025 4:57 pm
by sysctrl2
WaitRun
Re: No me funciona shellexecute. Saber caducidad certificado digital
Posted: Tue Mar 11, 2025 5:19 pm
by Garbi
lo he puesto asi:
Code: Select all | Expand
vresultado:=waitrun("..\openssl\bin\openssl.exe x509 -in ..\dbf\b96370556.pem -noout -enddate >..\dbf\fecha.txt")
msgalert(vresultado)
Y el vresultado es 1,que un resultado que no aparece en la ayuda de waitrun
Y además de que no me crea el fichero fecha.txt me abre una ventana y se cierra, cuando con shellexecute no abre ninguna ventana cuando "realiza" el comando
¿Algo estoy haciendo mal? ¿Alguna sugerencia?
Re: No me funciona shellexecute. Saber caducidad certificado digital
Posted: Tue Mar 11, 2025 7:01 pm
by sysctrl2
prueba copiando los archivos en en la carpeta de tu aplicación.
Code: Select all | Expand
cFileCer := "b96370556.pem"
cToTxt := "fecha.txt"
bBloc := {|cCer, cTxt| "openssl.exe x509 -in " + cCer + " -noout -enddate > " + cTxt }
WaitRun( (Eval(bBloc , cFileCer, cToTxt )), 0 )
saludos
Re: No me funciona shellexecute. Saber caducidad certificado digital
Posted: Wed Mar 12, 2025 11:06 am
by Ariel
Buenas,
prueba de poner el path completo, reemplace ..\ por c:\....turuta
Slds.
Re: No me funciona shellexecute. Saber caducidad certificado digital
Posted: Wed Mar 12, 2025 12:13 pm
by cmsoft
Puedes probar haciendo un bat con los comandos que deseas, y despues lanzar ese bat
Code: Select all | Expand
cComando := cComando + '..\openssl\bin\openssl.exe x509 -in ..\dbf\certificado.pem -noout -enddate >..\dbf\fecha.txt'
memowrit( 'cert.bat', cComando )
WaitRun( 'cert.bat' , 0 )
Re: No me funciona shellexecute. Saber caducidad certificado digital
Posted: Wed Mar 12, 2025 3:53 pm
by Garbi
Cesar, funcionado perfectamente.
Muchas gracias.
Ahora tocar obtener una fecha validad de la información que da.
Pero eso ya es más sencillo. Solo leer caracteres y transformar el mes.
Ejemplo de fecha.txt : notAfter=Dec 27 10:16:45 2026 GMT -> 27/12/2026
Un saludo