使用 Delphi 7 和 chilkat 库,我尝试使用智能卡对站点进行身份验证并发布 pdf 文件以获得上传索引。我迷失在 chilkat 所提供的一切中,而且我对这部分编程(使用智能卡、SSL/TLS、证书、REST 等)有点陌生。我该怎么做?
这是我的代码的一部分,我被困在帖子部分。
http := CkHttp_Create();
cert := CkCert_Create();
success := CkCert_LoadFromSmartcard(cert, '');
if (success = False) then
begin
Memo1.Lines.Add(CkCert__lastErrorText(cert));
Memo1.Lines.Add('Certificate not loaded.');
Exit;
end;
if (CkCert_HasPrivateKey(cert) <> True) then
begin
Memo1.Lines.Add('A private key is needed for TLS client authentication.');
Memo1.Lines.Add('This certificate has no private key.');
Exit;
end;
sock := CkSocket_Create();
success := CkSocket_SetSslClientCert(sock, cert);
if (success <> True) then
begin
Memo1.Lines.Add(CkSocket__lastErrorText(sock));
Exit;
end;
bTls := True;
port := 443;
maxWaitMs := 5000;
success := CkSocket_Connect(sock, mysite, port, bTls, maxWaitMs);
if (success <> True) then
begin
Memo1.Lines.Add('Connect Failure Error Code: ' + IntToStr(CkSocket_getConnectFailReason(sock)));
Memo1.Lines.Add(CkSocket__lastErrorText(sock));
Exit;
end;
rest := CkRest_Create();
success := CkRest_UseConnection(rest, socket, bAutoReconnect);
if (success <> True) then
begin
Memo1.Lines.Add(CkRest__lastErrorText(rest));
Exit;
end;
这里我需要使用POST上传文件。
我尝试使用
httprequest
,但失败了,因为我需要使用智能卡进行身份验证。