EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Post request to server with certificate

#22935
Posted: 12/19/2012 10:46:21
by Ernesto Alconada (Basic support level)
Joined: 11/01/2012
Posts: 26

I want request to server with certificate. I'm not sure that the code I use is correct. Is it correct?
Code
    with TElWinCertStorage.Create(nil) do
      try
        SystemStores.Add('MY');
        MS:=TElMemoryCertStorage.Create(nil);
        try
          FrmPrincipal.ElHTTPSClient1.ClientCertStorage:=MS;
          FrmPrincipal.ElHTTPSClient1.ClientCertStorage.Add(Certificates[FrmPrincipal.ComboBoxValidacion.ItemIndex]);
          FrmPrincipal.ElHTTPSClient1.Post('https://www7.aeat.es/'+FrmPrincipal.CDSModelosAction.AsString,Parametros);
        finally
          FreeAndNil(MS);
        end;
      finally
        free;
      end;
#22936
Posted: 12/19/2012 10:57:08
by Ken Ivanov (Team)

Ernesto,

The code is fine... provided that you add the right certificate to the ClientCertStorage object and that it has the associated private key.
#22937
Posted: 12/19/2012 11:23:24
by Eugene Mayevski (Team)

Also in some rare cases you would need to add the complete certificate chain to MS storage. The Add method in above scenario doesn't copy the complete chain (maybe we could enhance Add method's functionality with such copying, but this is not trivial in generic case).


Sincerely yours
Eugene Mayevski

Reply

Statistics

Topic viewed 555 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS business operates as a division of /n software, inc. For more information, please read the announcement.

Got it!