ssl httpserver throwing 'Access violation at address 00000000. Read of address 00000000' error

This code is throwing a 'Access violation at address 00000000. Read of address 00000000' error in runtime. I'm trying to get the server to accept ssl requests but am having real trouble.

I also have ssleay32.dll & libeay32.dll saved in the debug folder. Any help appreciated:

ServerIOHandler := TIdServerIOHandlerSSLOpenSSL.Create;

ServerIOHandler.SSLOptions.Method := sslvSSLv23;
ServerIOHandler.SSLOptions.Mode := sslmClient;
ServerIOHandler.SSLOptions.VerifyMode := [];
ServerIOHandler.SSLOptions.VerifyDepth := 0;

server:=TIdHTTPServer.Create;
server.IOHandler := ServerIOHandler;       
server.DefaultPort:=port;              
server.Bindings.DefaultPort:=port;

server.OnQuerySSLPort(8092, newBool);     //this is the line that throws the error

server.AutoStartSession:=true;
server.OnCommandGet:=idhttpserver1commandget;
server.SessionTimeOut:=360;
server.Active:=True;

Answers


The reason why you get this error is that OnQuerySSLPort is an event, which you haven't assigned a handler for.

The point of the OnQuerySSLPort is that you should write a method and then assign it to this property of the TIdHTTPServer object. Then this method (that you have written) will be executed everytime the event is fired:

procedure TForm5.MyHandler(APort: TIdPort; var VUseSSL: Boolean);
begin
  // Do something
end;

procedure TForm5.FormCreate(Sender: TObject);
begin
  server := TIdHTTPServer.Create;
  server.OnQuerySSLPort := MyHandler;
  ...
end;

You might be more familiary with other events like TForm.OnCreate, TTimer.OnExecute, etc. These work the same way: you write a piece of code that the object then executes when the right time comes.


Need Your Help

Is it possible to get a reference to the raw image buffer for system.drawing.graphics class?

c# wpf image

I'm trying to render an image from an unmanaged control on to a WPF window. So far I'm able to get a working graphics object (because I'm able to overlay image to the unmanaged control). What I'm h...

c++ first person camera in directx

c++ camera directx fps

m a beginner programmer and im creating a project which allows me to walk around rooms via a first person camera so far i have the buildings drawn etc but now im stuck and don't know how to make a ...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.