Atozed Forums
Error on send https.post with certificate - Printable Version

+- Atozed Forums (https://www.atozed.com/forums)
+-- Forum: Open Source (https://www.atozed.com/forums/forum-19.html)
+--- Forum: Indy (https://www.atozed.com/forums/forum-9.html)
+--- Thread: Error on send https.post with certificate (/thread-3650.html)



Error on send https.post with certificate - Jose Antonio Begines - 11-25-2023

Good morning, when trying to make an https.post request with a certificate, I get the error: 
EIdOSSLLoadingKeyError with message: 'could not load key, check password. error: 0B080074:x509 certificate routines:X509_check_private_key:key values mismatch'.

My code is:
  data := TIdMultiPartFormDataStream.Create;
  http := TIdHTTP.Create;
  IdSSLIOHandler := TIdSSLIOHandlerSocketOpenSSL.Create;
  try
    IdSSLIOHandler.SSLOptions.SSLVersions := [sslvTLSv1, sslvTLSv1_1, sslvTLSv1_2];
    IdSSLIOHandler.SSLOptions.Mode := sslmClient;
    IdSSLIOHandler.SSLOptions.Method := sslvSSLv23;
    IdSSLIOHandler.SSLOptions.CertFile := 'certificado.pem';
    IdSSLIOHandler.SSLOptions.KeyFile := 'claveprivada.pem';

    IdSSLIOHandler.OnStatusInfoEx := IdSSLIOHandlerSocketOpenSSL1StatusInfoEx;
    http.IOHandler := IdSSLIOHandler;

    http.Request.ContentEncoding := 'utf-8';
    http.Request.ContentType := 'application/xml';
    http.Request.CharSet := 'utf-8';

    data.AddFile('UploadedXml', 'File.xml', '');
    try
      queRespuesta := http.Post('https://xxxxxxx', data);

    except
      on e:Exception do begin
        ShowMessage(e.Message);
      end;
    end;

  finally
    http.Disconnect;
    http.Free;
    data.Free;
    IdSSLIOHandler.Free;
  end;


Thanks for the help.


RE: Error on send https.post with certificate - rlebeau - 11-28-2023

You asked the same question on Delphi-PRAXIS and got some replies there:

https://en.delphipraxis.net/topic/10581-indy-httppost-with-certificate-could-not-load-key/


RE: Error on send https.post with certificate - Jose Antonio Begines - 11-28-2023

Yes, press the message at the same time in both forums, thank you.