Jump to content

José Antonio

Members
  • Content Count

    4
  • Joined

  • Last visited

Community Reputation

0 Neutral
  1. José Antonio

    Indy http.post with certificate: Could not load key

    I have created the files again from the .pfx and now I get the error: 'HTTP/1.1 421 Misdirected Request' Any suggestions? Thank you
  2. José Antonio

    Indy http.post with certificate: Could not load key

    The private key does not have a password. If I try to send again with the KeyFile uncommented it still gives me the same error. OnGetPassword event is never executed. My code: 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 := 'certificate.pem'; IdSSLIOHandler.SSLOptions.KeyFile := 'privatekey.pem'; IdSSLIOHandler.OnStatusInfoEx := IdSSLIOHandlerSocketOpenSSL1StatusInfoEx; IdSSLIoHandler.OnGetPassword := getPassword; http.IOHandler := IdSSLIOHandler; http.ReadTimeout := READ_TIMEOUT; http.Request.ContentEncoding := 'utf-8'; http.Request.ContentType := 'application/xml'; http.Request.CharSet := 'utf-8'; data.AddFile('UploadedXml', fileXml, ''); try queAnswer := http.Post('https://xxxxxxxxxxxxxxxxx', data); except on e:Exception do begin ShowMessage(e.Message); end; end; finally http.Disconnect; http.Free; data.Free; IdSSLIOHandler.Free; end; The event: procedure TTicketBai.getPassword(var Password: string); begin Password := 'thepassword'; end;
  3. José Antonio

    Indy http.post with certificate: Could not load key

    If I don't send the private key, I get the error 'HTTP/1.1 421 Misdirected Request'. My code: 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 := 'certificate.pem'; //IdSSLIOHandler.SSLOptions.KeyFile := 'privatekey.pem'; IdSSLIOHandler.OnStatusInfoEx := IdSSLIOHandlerSocketOpenSSL1StatusInfoEx; IdSSLIoHandler.OnGetPassword := getPassword; http.IOHandler := IdSSLIOHandler; http.ReadTimeout := READ_TIMEOUT; http.Request.ContentEncoding := 'utf-8'; http.Request.ContentType := 'application/xml'; http.Request.CharSet := 'utf-8'; data.AddFile('UploadedXml', fileXml, ''); try queAnswer := http.Post('https://xxxxxxxxxxxxxxxxx', data); except on e:Exception do begin ShowMessage(e.Message); end; end; finally http.Disconnect; http.Free; data.Free; IdSSLIOHandler.Free; end;
  4. Good morning, in Delphi 10.3, 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'. Thanks for the help.
×