danieleteti

DMVCFramework :: SSL Config

Sep 29th, 2020
374
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.15 KB | None | 0 0
  1. procedure RunServer(APort: Integer);
  2. var
  3.   LServer: TIdHTTPWebBrokerBridge;
  4.   LGetSSLPassword: TGetSSLPassword;
  5.   LIOHandleSSL: TIdServerIOHandlerSSLOpenSSL;
  6. begin
  7.   Writeln(Format('Starting DMVCFramework HTTPS Server or port %d', [APort]));
  8.   LGetSSLPassword := nil;
  9.   LServer := TIdHTTPWebBrokerBridge.Create(nil);
  10.   try
  11.     LGetSSLPassword := TGetSSLPassword.Create;
  12.     LIOHandleSSL := TIdServerIOHandlerSSLOpenSSL.Create(LServer);
  13.     LIOHandleSSL.SSLOptions.SSLVersions := [
  14.       TIdSSLVersion.sslvSSLv23,
  15.       TIdSSLVersion.sslvSSLv3,
  16.       TIdSSLVersion.sslvTLSv1,
  17.       TIdSSLVersion.sslvTLSv1_1,
  18.       TIdSSLVersion.sslvTLSv1_2
  19.       ];
  20.     LIOHandleSSL.SSLOptions.Mode := sslmServer;
  21.     LIOHandleSSL.SSLOptions.CertFile := 'cacert.pem';
  22.     LIOHandleSSL.SSLOptions.RootCertFile := '';
  23.     LIOHandleSSL.SSLOptions.KeyFile := 'privkey.pem';
  24.     LIOHandleSSL.OnGetPassword := LGetSSLPassword.OnGetSSLPassword;
  25.     LServer.IOHandler := LIOHandleSSL;
  26.     LServer.DefaultPort := APort;
  27.  
  28.     LServer.Active := True;
  29.     Writeln('Press RETURN to stop the server');
  30.     ReadLn;
  31.   finally
  32.     LServer.Free;
  33.     LGetSSLPassword.Free;
  34.   end;
  35. end;
Add Comment
Please, Sign In to add comment