NetTalk Central

Author Topic: switch between SSL and non SSL for desktop development.  (Read 5889 times)

rjolda

  • Sr. Member
  • ****
  • Posts: 329
    • View Profile
    • Email
switch between SSL and non SSL for desktop development.
« on: February 20, 2018, 02:34:01 PM »
Hi All,
Have a web app NT 10.15 , C8.0.9661.
I have a secure server on the web running my app in SSL with certificates.
PROBLEM:  I need to run the app locally on my dev. machine for testing in local mode - eg port 90.
I have the following embeds in webServer.Init:

 set:Domains = 'www.MyDomain.com'
          set:SecurePort= 443
       set:InsecurePort = 90

Runs great on my server.
However, to test locally, if I comment out:
  !set:Domains = 'www.MyDomain.com'
   !       set:SecurePort= 443
       set:InsecurePort = 90

It still runs on port 443 and I can't run it locally.....
How do folks get around this???
TIA,
Ron Jolda

bshields

  • Sr. Member
  • ****
  • Posts: 392
    • View Profile
    • Inhabit
    • Email
Re: switch between SSL and non SSL for desktop development.
« Reply #1 on: February 20, 2018, 03:56:54 PM »
Hi Ron,

I edit my hosts file (located usually at C:\Windows\System32\drivers\etc\hosts).

The host file has no extension and will likely require local administrator access on your computer to edit.

I then place at the bottom

127.0.0.1 mydomainname.com

This will locally redirect any application on your computer trying to access mydomainname.com to the IP 127.0.0.1 (you can redirect it to other IP address if your computer has multiple IPs).

This means 1. your SSL certificate will work normally and 2. you wont be able to access that URL externally while the hosts file is changed - but just edit it back when you need to go to the real domain).

Once you save the hosts file it takes effect immediately, no reboot required.

Regards
Bill

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: switch between SSL and non SSL for desktop development.
« Reply #2 on: February 20, 2018, 09:57:01 PM »
Hi Ron,

This answer will be in multiple parts, because I believe your "problem" is that you are assuming something which is not fact. So this answer will take the form of a number of questions which will lead us to the incorrect assumption.

a) >> PROBLEM:  I need to run the app locally on my dev. machine for testing in local mode

So, just to be clear, you have a server out there on the web with a dns name and a certificate, but of course you are developing locally on your machine. So you run locally, then deploy to the server once you are ready?

b) what URL do you use for your main server, and what URL for your local machine?

I presume you are using the Settings Control template on the WebServer window. Are you?

Cheers
Bruce

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: switch between SSL and non SSL for desktop development.
« Reply #3 on: February 20, 2018, 09:59:56 PM »
Hi Bill,

here's a slight modification to the way you do it.
a) say you have www.bill.com then add a DNS entry for local.bill.com and point it to the same IP address.
b) On the server set the domains list to www.bill.com, local.bill.com and Get Certificates.
c) copy the whole certificates folder to your local dev machine.
d) Edit LocalHosts to point local.bill.com at 127.0.0.1

Now every 3 months or so you'll need to copy a new set of certificates from www to your local machine. But you can access either site at any time (or the same time) without the need to further edit the localhost file.

Cheers
Bruce

bshields

  • Sr. Member
  • ****
  • Posts: 392
    • View Profile
    • Inhabit
    • Email
Re: switch between SSL and non SSL for desktop development.
« Reply #4 on: February 21, 2018, 01:12:20 AM »
Hi Bruce,

Yeah I sort of do it like that, myself.

My dev boxes will have a url like:

p7720.bill.com (p7720 being my machine name - and only setup via hosts file).

bill.com will be the production box main url.

So that way I don't have to edit my hosts file.

I also have QA servers and more than one dev box so it allows me lots of flexibility.

I was just keeping my example simple.

Regards
Bill

rjolda

  • Sr. Member
  • ****
  • Posts: 329
    • View Profile
    • Email
Re: switch between SSL and non SSL for desktop development.
« Reply #5 on: February 21, 2018, 04:35:38 AM »
HI Bruce,
I have Certificate for my domain www.mydomain.com which is hosted on a remote server at a fixed IP address.  https://www.mydomain.com   to reach app running on port 447.
Locally, I am tesing the development app at  127.0.0.1:90.  (or trying to...).
Using the Server setup parameters at Server.Init as noted in first posting.
Thanks,
ROn

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: switch between SSL and non SSL for desktop development.
« Reply #6 on: February 26, 2018, 01:31:46 AM »
Hi Ron,

don't test locally in insecure more, test locally in secure mode.

cheers
Bruce