0

Hello currently i am in project making progressive-web app using my local webserver-express. Im totally in my confusion after so many days no progress.

because I need to use PWA in my phone then I really need to enable https for service-worker.

I have tried using self-signed cerf, it doesnt work for the service worker and there is a way to enable http with service-worker but it only accessible in PC-chrome while i really need the service-worker works in my android or smartphone not in my PC-only.

so I just bought the real cerf to attain HTTPS and i am little bit confused because im still unfamiliar with domain etc.

I follow this guide JUST bought my ssl and a new domain cause i run my PWA in my local webserver.

but my domain is still new so it's still locked for 60days, I don't know if i buy in another site it will be locked or not and will have to buy a new ssl again.

I got 4 cerf :

  1. my domain cerf

  2. Root cerf

  3. Intermediate cerf

  4. Webserver cerf

so i try to run my webserver express in my local ip+port with these 4 cerfs and so here the questions because i have little knowledge :

  1. My domain cerf and intermediate shouldnt be work because my domain is still locked right ?
  2. My root cerf doesnt work either in my local-webserver even tho i have imported the cerf in chrome. ( the https is still red, i could access the my site but i don't need red https because the service worker need green-https (?) )
  3. I don't know what to do with webserver-cerf , well I did applied it in my code, it do nothing either.

    options = {
      key: fs.readFileSync(path.join(certsPath, 'my-server.key.pem'))
    
      , ca: [
        fs.readFileSync(path.join(caCertsPath, 'webserver.crt.pem'))
    
      ,fs.readFileSync(path.join(caCertsPath, 'intermediate.crt.pem'))
            ,fs.readFileSync(path.join(caCertsPath, 'my-root-
       ca.crt.pem'))
              ]
    
    , cert: fs.readFileSync(path.join(certsPath, 'my-server.crt.pem'))
    
    , requestCert: false
    , rejectUnauthorized: true
    };
    

later :

https.createServer(options, app);

I assumed you guys know how this works right ? nodejs.express

I don't really think the code for webserver is the problem but more like the cert-understanding, domain-world and how local-webserver works with https. The more i research the more i confused now.

I run https://ip:port none of the working with my https-cerf.

basicly i just need to make green HTTPS in my local webserver, but how ? I did bought the cerf and it doesnt work, so before i bought another i have to make sure what kind of problem i have right now ?

another question: my domain is unlocked but there is nameserver while i dont have host-provider, could i use my local-ip to the nameserver ? im seriously confused how this things work now. I don't even know what is the thing i confused right now, don't know what to ask.

sorry for bad grammar, but i would like if you guys correct mine.

EDIT : mistaken unlocked and locked

Dell Watson
  • 367
  • 1
  • 3
  • 13

1 Answers1

0

Service workers normally require https:, but localhost is the exception. Any http://localhost:<port> origins will work with service workers.

Since you mention needing to test things on your phone, and assuming it's an Android device and you're using Chrome, the information in the "Access Local Servers" guide should help you.

You can run a local web server and then use Chrome to forward the port to an Android device connected via a USB cable, and the Android device can load your content and take full advantage of service workers via the same http://localhost:<port> origin.

Jeff Posnick
  • 53,580
  • 14
  • 141
  • 167