Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread how to ensure HTTPS
Tue, Feb 16 2016 9:17 AMPermanent Link

erickengelke

Hi, this is my first contribution BACK to EWS.  If you are passing passwords and the like, you will want to be sure to use HTTPS.   This code will test for HTTPS and convert to HTTPS if not running on the local machine (ie. debugging)



function CheckHTTPS: boolean;
var
 hostname : string;
 protocol : string;
begin
 protocol := LowerCase(window.location.protocol);
 hostname := LowerCase(window.location.hostname);
 result :=  ( hostname = 'localhost') or ( protocol = 'https:');
end;

procedure MakeHTTPS;
var
 s : string;
 hostname, port, search : string;
 pathname , name : string;
begin
 if  not CheckHTTPS then begin
   hostname := window.location.hostname;
   port := window.location.port;
   search := window.location.search;
   pathname := window.location.pathname;

   s := 'https:' + hostname;
   if ( port <> '' ) then s := s + ':'+ port;
   if (pathname <> '') then s := s + '/' + pathname;
   
   window.location.replace( s );
 end;
end;
Tue, Feb 16 2016 9:44 AMPermanent Link

erickengelke

erickengelke wrote:

> If you are passing passwords and the like, you will want to be sure to use HTTPS.

The correct code is:


function CheckHTTPS: boolean;
var
 hostname : string;
 protocol : string;
begin
 protocol := LowerCase(window.location.protocol);
 hostname := LowerCase(window.location.hostname);
 result :=  ( hostname = 'localhost') or ( protocol = 'https:');
end;

procedure MakeHTTPS;
var
 s : string;
 hostname, port, search : string;
 pathname , name : string;
begin
 if  not CheckHTTPS then begin
   hostname := window.location.hostname;
   port := window.location.port;
   search := window.location.search;
   pathname := window.location.pathname;

   s := 'https:' + hostname;
   if ( port <> '' ) then s := s + ':'+ port;
   if (pathname <> '') then s := s + pathname;
   if ( search <> '' ) then s := s + search;
   
   window.location.replace( s );
 end;
end;
 
Image