Mirando el código dónde se supone que usa la información del certificado (D12)
Código Delphi
[-]
unit System.Net.HttpClient.Win;
...
procedure TWinHTTPRequest.SetWinCertificate;
var
LStore: HCERTSTORE;
LCertContext: PCCERT_CONTEXT;
LBlob: CRYPT_DATA_BLOB;
LBytes: TBytes;
begin
if (FClientCertPath = '') and (FClientCertificate = nil) then
Exit;
if FClientCertPath <> '' then
LStore := CertOpenStore(PAnsiChar(CERT_STORE_PROV_FILENAME), X509_ASN_ENCODING or PKCS_7_ASN_ENCODING,
0, CERT_STORE_OPEN_EXISTING_FLAG or CERT_STORE_READONLY_FLAG, PChar(FClientCertPath))
else
begin
LBlob.cbData := FClientCertificate.Size;
SetLength(LBytes, LBlob.cbData);
FClientCertificate.Position := 0;
FClientCertificate.Read(LBytes, LBlob.cbData);
LBlob.pbData := PByte(@LBytes[0]);
LStore := PFXImportCertStore(@LBlob, PChar(FClientCertPassword), 0);
end;
if LStore = nil then
raise ENetHTTPRequestException.CreateResFmt(@SNetHttpCertFileOpenError,
[GetLastError, SysErrorMessage(GetLastError, TWinHttpLib.Handle)]);
try
LCertContext := nil;
if CheckWin32Version(6, 2) then
LCertContext := CertFindCertificateInStore(LStore, X509_ASN_ENCODING or PKCS_7_ASN_ENCODING,
0, CERT_FIND_HAS_PRIVATE_KEY, nil, nil);
if LCertContext = nil then
LCertContext := CertFindCertificateInStore(LStore, X509_ASN_ENCODING or PKCS_7_ASN_ENCODING,
0, CERT_FIND_ANY, nil, nil);
if LCertContext = nil then
raise ENetHTTPRequestException.CreateResFmt(@SNetHttpCertNotFoundError,
[GetLastError, SysErrorMessage(GetLastError, TWinHttpLib.Handle)]);
try
WinHttpSetOption(FWRequest, WINHTTP_OPTION_CLIENT_CERT_CONTEXT,
LCertContext, SizeOf(CERT_CONTEXT));
finally
CertFreeCertificateContext(LCertContext);
end;
finally
CertCloseStore(LStore, 0);
end;
end;
Si le pasas un nombre de fichero, no espera un PFX sino un fichero con un almacen de certificados (funcion CertOpenStore)
https://learn.microsoft.com/es-es/wi...-certopenstore
Mira los formatos que acepta en la ayuda
En cambio si pasas un Stream,
sí que espera que sea un PFX. Ese debería de funcionarte.
Cosas que se me ocurren que porqué no va el stream, prueba a poner Position a cero antes de usarlo y revisa que estás grabando bien el PFX en el stream.