1

I use remote staging server to test my PWA application which is under development and based on Magento 2.3 Venia theme. I see the Node instance generates devcert certificate automatically on application run. But it is not trusted by browsers of course. I have my own Lets encrypt certificate for staging domain and want to force using it for my application.

How can I do it? I found only instructions of how to specify custom cert files for Express.js app, but Magento 2 PWA studio is quite complex and I don't know where should I specify it.

0

In packages/package-name/.env :

MAGENTO_BUILDPACK_SECURE_HOST_SSL_KEY='path/to/file'

MAGENTO_BUILDPACK_SECURE_HOST_SSL_CERT='path/to/file'

In packages/package-name/webpack.config.js :

        devServerConfig.provideSecureHost = {
            subdomain: validEnv.MAGENTO_BUILDPACK_SECURE_HOST_SUBDOMAIN,
            exactDomain:
                validEnv.MAGENTO_BUILDPACK_SECURE_HOST_EXACT_DOMAIN,
            addUniqueHash: !!validEnv.MAGENTO_BUILDPACK_SECURE_HOST_ADD_UNIQUE_HASH,
            keyFile: validEnv.MAGENTO_BUILDPACK_SECURE_HOST_SSL_KEY,
            certFile: validEnv.MAGENTO_BUILDPACK_SECURE_HOST_SSL_CERT
        };

In packages/pwa-buildpack/src/WebpackTools/PWADevServer.js :

    devServerConfig.https =
        hostConf.certFile && hostConf.keyFile
            ? {
                  key: readFileSync(hostConf.keyFile, 'utf-8'),
                  cert: readFileSync(hostConf.certFile, 'utf-8')
              }
            : ssl;
0

It is wrong. In the latest version, in package/package-name/.env file

There are 2 config, just put your key & cert absolute path there.

#### Custom HTTPS certificates #################################################
#
#   Absolute path to the custom HTTPS certificate key file.
#   - Default when not set: 
CUSTOM_HTTPS_KEY=
#
#   Absolute path to the custom HTTPS certificate cert file.
#   - Default when not set: 
CUSTOM_HTTPS_CERT=

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.