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;