How to add self signed SSL certificate to jHipster sample app?

后端 未结 3 833
误落风尘
误落风尘 2020-12-04 09:04

I have create sample jHipster app. Now I want to add self signed SSL certificate and test in local to have a access to https. How to achieve this?

3条回答
  •  生来不讨喜
    2020-12-04 09:48

    To extend the Driss Amri brilliant answer on how to re-enable BrowserSync.

    If you choose not to support http, or if http is redirected to https, BrowserSync will not work. To make it work again, few changes are necessary in:

    1. gulp/config.js, apiPort and uri to:

      apiPort: 8443, 
      uri: 'https://localhost:',
      
    2. gulp/serve.js: add options.rejectUnauthorized = false; into proxyRoutes so that node does not complain about self signed certificate:

      proxyRoutes.map(function (r) {
          var options = url.parse(baseUri + r);
          options.route = r;
          options.preserveHost = true;
          options.rejectUnauthorized = false;
          return proxy(options);
      }));
      
    3. optionally let BrowserSync serve content over https too. I recommend it with Spring Social to save some trouble. Just add https: true into browserSync call in gulp/serve.js:

      browserSync({
          open: true,
          port: config.port,
          server: {
              baseDir: config.app,
              middleware: proxies
          },
          https: true
      });
      

      Now BrowserSync will serve content with self signed certificate shipped with it. It is possible to reuse the one created for Spring Boot, more on BrowserSync homepage.

提交回复
热议问题