Atozed Forums

Full Version: Error on send https.post with certificate
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.
You asked the same question on Delphi-PRAXIS and got some replies there:

https://en.delphipraxis.net/topic/10581-...-load-key/
Yes, press the message at the same time in both forums, thank you.