Sí, más o menos es a lo que se había llegado durante el hilo.
Como añadido, un problema que tiene el sistema de selección de certificado de un PFX y que me di cuenta hace unos meses:
En la carpeta
%appdata%Microsoft\Crypto\RSA\S-1-5-21-algomas se van creado archivos temporales con las claves que no se eliminan y puedes terminar con miles de archivos (o en la carpeta equivalente en %programdata% si se usa el almacén de la máquina en vez del usuario)
La solución pasa por usar este código al terminar el uso del certificado:
Código Delphi
[-]
procedure CertContexFree(pCert: PCERT_CONTEXT; pStore: HCERTSTORE);
var
hProv: HCRYPTPROV;
c: Cardinal;
Info: PCRYPT_KEY_PROV_INFO;
ContainerName,
ProvName: WideString;
ProvType: Cardinal;
begin
if Assigned(pCert) then
begin
CertGetCertificateContextProperty(pCert, CERT_KEY_PROV_INFO_PROP_ID, nil, c);
Info := AllocMem(c);
CertGetCertificateContextProperty(pCert, CERT_KEY_PROV_INFO_PROP_ID, Info, c);
ContainerName := Info.pwszContainerName;
ProvName := Info.pwszProvName;
ProvType := Info.dwProvType;
FreeMem(Info);
CertFreeCertificateContext(pCert);
CryptAcquireContext(hProv, PWideChar(ContainerName), PWideChar(ProvName), ProvType, CRYPT_DELETEKEYSET);
end;
if Assigned(pStore) then
CertCloseStore(pStore, 0);
end;