我有一个使用sTunnel在Windows Server 2012R2上运行的Web服务。 使用Postman时,我必须先进行SSL验证才能正常工作,否则会得到:没有连接错误。
一些使用我们的Delphi Windows应用程序的客户端收到错误HTTP 1.1 500和消息Reject(由于策略限制)。
sTunnel日志中显示以下内容:SSL例程:ssl3_read_bytes:sslv3警报证书不明
我在System32文件夹中有最新打开的SSl dll。
我不知道是否可以在Delphi或sTunnel中打开/关闭某些内容。
这是用于发送SMS并将结果发送到我的网络服务器的代码。
procedure SendSMS.Execute;
var
JsonToSend: TStringStream;
url, SMSText, Rtext, AppId, Json: String;
IdHTTP1: TIdHTTP;
IdSSLIOHandlerSocketOpenSSL2: TIdSSLIOHandlerSocketOpenSSL;
jsonRecived: TJSONObject;
begin
AppId := 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx';
mySMSSent := False;
if (Length(DataM1.ComTbl.FieldByName('SMSToken').AsString) > 10) and (Length(SMSMessageText) > 3) then
begin
SMSText := StringReplace(SMSMessageText,#$A,'\n',[rfReplaceAll, rfIgnoreCase]);
SMSText := StringReplace(SMSText,#$D,'',[rfReplaceAll, rfIgnoreCase]);
Try
IdSSLIOHandlerSocketOpenSSL2 := TIdSSLIOHandlerSocketOpenSSL.Create;
IdHTTP1 := TIdHTTP.Create;
IdHTTP1.Request.UserAgent := 'Mozilla/3.0 (compatible; Indy Library)';
IdHTTP1.Request.ContentType := 'application/json';
IdHTTP1.Request.BasicAuthentication := true;
IdHTTP1.Request.Username := SMSPass;
IdHTTP1.Request.Password := SMSToken;
IdSSLIOHandlerSocketOpenSSL2.SSLOptions.Method := sslvTLSv1_2;
IdHTTP1.IOHandler := IdSSLIOHandlerSocketOpenSSL2;
IdHTTP1.HandleRedirects := False;
if Length(SMSMedia) > 5 then
Json := '{"from": "+1' + SMSPhone + '","to": "+1' + ToPhone + '","text": "' + SMSText + '","applicationId": "' + AppId + '","media": "' + SMSMedia + '","tag": "' + NameID + '"}'
else
Json := '{"from": "+1' + SMSPhone + '","to": "+1' + ToPhone + '","text": "' + SMSText + '","applicationId": "' + AppId + '","tag": "' + NameID + '"}';
url:='https://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx?';
JsonToSend := TStringStream.Create(Json);
try
Rtext:=IdHTTP1.Post(url, JsonToSend);
except
on E:Exception do
begin
SMSText := E.Classname + ': ' + E.Message;
mySMSSent := True;
end;
end;
if Pos('owner',Rtext) > 0 then // Send to web service //
begin
jsonRecived := TJSONObject.create(rtext);
if jsonRecived <> nil then
begin
Json := '{"id": "';
Json := Json + jsonRecived.optString('id') + '","from": "+1';
Json := Json + SMSPhone + '","time": "';
Json := Json + jsonRecived.optString('time') + '","direction": "';
Json := Json + jsonRecived.optString('direction') + '","text": "';
Json := Json + SMSText + '","to": "+1' + ToPhone + '"}';
Try
if Assigned(JsonToSend) then
FreeAndNil(JsonToSend);
JsonToSend := TStringStream.Create(Json);
url:='https://mywebservice';
IdHTTP1.Post(url, JsonToSend);
Except
End;
end;
end;
Finally
IdHTTP1.Disconnect;
IdSSLIOHandlerSocketOpenSSL2.Free;
IdHTTP1.Free;
JsonToSend.Free;
End;
end;
end;