Jump to content

isnagil

Members
  • Content Count

    1
  • Joined

  • Last visited

Community Reputation

0 Neutral

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Hello! I have to communicate with a webservice using a certificate. I'm trying to load a certificate by directly reading a pfx file to avoid the certificate selection screen being displayed. This prompt: I found this on the web but it is from a delphi 2010 version and I use 10.4. The parameters of the event have changed and the compiler doesn´t reconize data variable. HTTPRIO1HTTPWebNode1BeforePost(const HTTPReqResp: THTTPReqResp; Client: THTTPClient); procedure CheckError(Point: Pointer); begin if not Assigned(Point) then RaiseLastOSError; end; const INTERNET_OPTION_CLIENT_CERT_CONTEXT = 84; PKCS12_INCLUDE_EXTENDED_PROPERTIES = $0010; CERT_COMPARE_HAS_PRIVATE_KEY = 21; CERT_FIND_HAS_PRIVATE_KEY = CERT_COMPARE_HAS_PRIVATE_KEY shl CERT_COMPARE_SHIFT; Pass = 'XXXXXXXXXX'; var pStore: HCERTSTORE; pCert: PCERT_CONTEXT; DataBlob: CRYPT_BIT_BLOB; PFX: TBytes; begin pStore := nil; pCert := nil; PFX := TFile.ReadAllBytes(ExtractFilePath(Application.ExeName) + 'NameOfCertificate.pfx'); try DataBlob.cbData := Length(PFX); DataBlob.pbData := @PFX[0]; pStore := PFXImportCertStore(DataBlob, PWideChar(Pass), PKCS12_INCLUDE_EXTENDED_PROPERTIES); CheckError(pStore); pCert := CertFindCertificateInStore(pStore, X509_ASN_ENCODING, 0, CERT_FIND_HAS_PRIVATE_KEY, //CERT_FIND_ANY, nil, nil); CheckError(pCert); InternetSetOption(Data, INTERNET_OPTION_CLIENT_CERT_CONTEXT, pCert, SizeOf(CERT_CONTEXT)); finally if Assigned(pCert) then CertFreeCertificateContext(pCert); if Assigned(pStore) then CertCloseStore(pStore, 0); end; end; Older version: HTTPRIO1HTTPWebNode1BeforePost(const HTTPReqResp: THTTPReqResp; Data: Pointer); New version: HTTPRIO1HTTPWebNode1BeforePost(const HTTPReqResp: THTTPReqResp; Client: THTTPClient); Can someone help me?
×