Ver Mensaje Individual
  #108  
Antiguo 07-02-2025
Avatar de DarkDudae
DarkDudae DarkDudae is offline
Miembro
 
Registrado: abr 2006
Posts: 177
Reputación: 21
DarkDudae Va por buen camino
Nueva sugerencia para el componente:

Obtener fechas de caducidad de los certificados.

Para ello, bastaría con hacer una pequeña modificación en la función loadCertificados y en el tipo TCertificados.

Código Delphi [-]
function loadCertificados(aList, aFechas:TStringList):integer;
var
  hStore: HCERTSTORE;
  PrevContext, CurContext: PCERT_CONTEXT;
  cbSize: DWORD;
  SysTime: TSystemTime;
  sNombre: String;
begin
  aList.Clear;
  aFechas.Clear;
  Result := 0;
  hStore := CertOpenSystemStore(0, PChar('MY'));
  if hStore <> nil then begin
     PrevContext := nil;
     CurContext := CertEnumCertificatesInStore(hStore, PrevContext);
     while CurContext <> nil do begin
       sNombre := '';
       cbSize := CertGetNameString(CurContext, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0, nil, nil, 0);
       if cbSize > 0 then
       begin
          SetLength(sNombre, cbSize-1);
          CertGetNameString(CurContext, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0, nil, PChar(sNombre), cbSize);
          aList.Add(sNombre);
          if FileTimeToSystemTime(CurContext^.pCertInfo^.NotAfter, SysTime) then
          begin
            AFechas.Add(datetimetostr(SystemTimeToDateTime(SysTime)));
          end;
       end;
       PrevContext := CurContext;
       CurContext  := CertEnumCertificatesInStore(hStore, PrevContext);
     end;
  end;
  result:=aList.count;
end;