Jump to content
robhercarlos

No protocols available

Recommended Posts

Hello,

 

have a problem with a Win32 application using Indy. I am using Delphi 10.4 and am trying to make an XML Post request, but on making the call I get this error message:

"ERROR: Error connecting with SSL. error: 140740BF:SSL routines:SSL23_CLIENT_HELLO:no protocols available"

 

I am new to API's and I'm not sure in which direction to go next when trying to figure this out. Any suggestions or tips would be greatly appreciated.

 

Below is the code I am using.

procedure TformEditCUMaster.btnE2EstimateClick(Sender: TObject);
var
  (* Document in XML to send *)
  ProntoResidentialXML, ResidentialXML: String;
  RESIDENTIAL_BASEURL, PRONTO_RESIDENTIAL_BASEURL: String;

  Username, Password: String;

  (* SSL Configuration *)
  ssl: TIdSSLIOHandlerSocketOpenSSL;

  EncodedXMLToSend: String;

  (* Used for API *)
  IdHttp: TidHttp;
  ReturnStr: String;
  (* Variables used in second attmp *)
  ResponseStream: TMemoryStream;
  InputStringList: TStringList;
begin
  CodeSite.EnterMethod('TformEditCUMaster.btnE2EstimateClick');
  //Inherited;

  (* Here add the login credentials *)
  (* Will be adding users own E2 value username and password *)
  Username := 'username';
  Password := 'password';

  (* Here are the BaseURLS *)
  RESIDENTIAL_BASEURL := 'https://evs.e2value.com/evs/xml/ballparkresidential.asp';
  PRONTO_RESIDENTIAL_BASEURL := 'https://evs.e2value.com/evs/xml/1_0/pronto/default.aspx';

  (* Send out request to e2 value that will retrieve an estimate on data provided. *)
  IdHttp := TidHttp.Create();
  try
    (* Focus on Coverage unit for the current policy *)
    CovUnit.Locate('POLICY;SEQUENCE',
      VarArrayOf([Policy.FieldByName('POLICY').AsString,
      Policy.FieldByName('SEQUENCE').AsString]), [loPartialKey]);
    
    ResidentialXML := '<?xml version="1.0"?>'
            + '<estimate username="username" password="password">'
            + '        <version>1.0</version>'
            + '        <property>'
            + '                <address1>'+ Policy.FieldByName('ADDR1').AsString +'</address1>'
            + '                <address2>'+ Policy.FieldByName('ADDR2').AsString +'</address2>'
            + '                <city>' + Policy.FieldByName('CITY').AsString + '</city>'
            + '                <state>Virginia</state>'
            + '                <zipcode>'+ Policy.FieldByName('ZIP').AsString +'</zipcode>'
            + '                <locale></locale>'
            + '                <coverage_a>'+ CovUnit.FieldByName('COVA').AsString +'</coverage_a>'
            + '                <architectural_style></architectural_style>'
            + '                <construction_quality></construction_quality>'
            + '                <physical_shape></physical_shape>'
            + '                <construction_type></construction_type>'
            + '                <recent_renovations></recent_renovations>'
            + '                <historic_registry></historic_registry>'
            + '                <primary_exterior></primary_exterior>'
            + '                <primary_roof_covering>architectural shingle</primary_roof_covering>'
            + '                <living_area>'
            + '                        <year_built>1990</year_built>'
            + '                        <square_footage>1,000</square_footage>'
            + '                </living_area>'
            + '                <other_areas>'
            + '                        <area>'
            + '                                <area_name>breeze way</area_name>'
            + '                                <year_built>1990</year_built>'
            + '                                <square_footage>100</square_footage>'
            + '                        </area>'
            + '                </other_areas>'
            + '                <unique_items>'
            + '                        <item>'
            + '                                <item_name>gargoyle</item_name>'
            + '                                <cost>$500.00</cost>'
            + '                        </item>'
            + '                </unique_items>'
            + '                <replacement_cost_type>full</replacement_cost_type>'
            + '                <return_acv value="yes">'
            + '                        <structure_in_use>yes</structure_in_use>'
            + '                        <condition>'
            + '                                <general>good</general>'
            + '                                <roof>good</roof>'
            + '                                <wall>good</wall>'
            + '                                <foundation>good</foundation>'
            + '                        </condition>'
            + '                </return_acv>'
            + '        </property>'
            + '</estimate>';

    //EncodedXMLToSend := TNetEncoding.URL.Encode(XMLDocument);

    ResponseStream := TMemoryStream.Create;
    InputStringList := TStringList.Create;

    InputStringList.Values['xml'] := ResidentialXML;


  (* attempt call to api *)
    Try
      (* Configure SSL options as needed... *)
      SSL := TIdSSLIOHandlerSocketOpenSSL.Create;
      SSL.SSLOptions.SSLVersions := [sslvTLSv1_1, sslvTLSv1_2, sslvSSLv23];
      IdHTTP.IOHandler := SSL;

      (* Configure the http *)
      IdHttp.Request.ContentType := 'application/x-www-form-urlencoded';
      IdHttp.Post(RESIDENTIAL_BASEURL, InputStringList, ResponseStream);

      Memo1.Lines.Add(Format('Response Code: %d', [IdHTTP.ResponseCode]));
      Memo1.Lines.Add(Format('Response Text: %s', [IdHTTP.ResponseText]));

      ResponseStream.Position := 0;
      InputStringList.LoadFromStream(ResponseStream);
      Memo1.Lines.Add('---- Pronto Full Residential -----');
      Memo1.Lines.AddStrings(InputStringList);
      Memo1.Lines.Add('-----------------------');

    Finally
      ResponseStream.Free;
      InputStringList.Free;
    End;
  finally
    SSL.Free;
  end;

  CodeSite.ExitMethod('TformEditCUMaster.btnE2EstimateClick');
end;

 

I have updated and placed all my SLL .dll files in the same folder as my .exe file, but I'm still getting the same error message.

 

Could someone point me in the right direction?

Thanks!

 

- Roberto

 

Share this post


Link to post
1 hour ago, robhercarlos said:

SSL.SSLOptions.SSLVersions := [sslvTLSv1_1, sslvTLSv1_2, sslvSSLv23];

That line is effectively setting SSLOptions.Method to sslvSSLv23 and SSLOptions.SSLVersions to [sslvTLSv1_1, sslvTLSv1_2].  Which means, if the server does not support TLS 1.1 or TLS 1.2 then the TLS handshake will fail.  Typically, that line should be as follows instead:

SSL.SSLOptions.SSLVersions := [sslvSSLvTLS1, sslvTLSv1_1, sslvTLSv1_2];

The sslvSSLv23 flag has special meaning for Indy's internals and should not be used directly in most cases.  The only valid use for using sslvSSLv23 in your code is to enable all supported SSL/TLS versions, eg:

SSL.SSLOptions.Method := sslvSSLv23;
// will set Method=sslvSSLv23 and SSLVersions=[sslvSSLv2,sslvSSLv3,sslvTLSv1,sslvTLSv1_1,sslvTLSv1_2]

SSL.SSLOptions.SSLVersions := [sslvSSLv23];
// will set Method=sslvSSLv23 and SSLVersions=[sslvSSLv2,sslvSSLv3,sslvTLSv1,sslvTLSv1_1,sslvTLSv1_2]

Otherwise, just ignore that the sslvSSLv23 flag exists, and set the SSLVersions property to just the desired protocol versions (2/3 is not a protocol version, it is a wildcard).

Edited by Remy Lebeau
  • Like 1

Share this post


Link to post

Hey, thanks Remy!

 

Turns out it was one of my SLL .dll files that did not get updated when I made the changes.

 

I also went ahead and changed my SLLVersions property to the appropriate versions that I needed, and every thing is working how it should.

 

Also, thanks for explaining and helping me understand better what the sslvSSLv23 flag is for.

 

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×