Hostame/IP does not match certificate's altnames: Host: ***.***-assets.nyc3.digitaloceanspaces.com. is not in the cert's altnames: DNS:*.nyc3.digitaloceanspaces.com, DNS:nyc3.digitaloceanspaces.com

[details=“System Information”]

  • **Strapi Version4.6:
  • **Operating SystemUbuntu 18.04:
  • **DatabasePostgreSql:
  • **Node Versionv17.9.1:
  • **NPM Version8.11.0:
  • **Yarn Version1.22.19:

Am using strapi-provider-upload-do to upload files to digital spaces. Am getting [ERR_TLS_CERT_ALTNAME_INVALID]: Hostname/IP does not match certificate’s altnames: Host: .-assets.nyc3.digitaloceanspaces.com. is not in the cert’s altnames: DNS:*.nyc3.digitaloceanspaces.com, DNS:nyc3.digitaloceanspaces.com.

Uploading normally without spaces configuration works but am trying to use spaces.

Anyone with any fix or solution to this issue?


1 Like

@CodeDruid13 did you manage to make it work?
I’m having the same issue here.

same here, any solutions?

Final config that i reached to via trial/error because didn’t find solution anywhere else:

inside .env:

DO_SPACE_ACCESS_KEY=****
DO_SPACE_SECRET_KEY=****

DO_SPACE_ENDPOINT=nyc3.digitaloceanspaces.com  // remove https and the space name from the DO origin endpoint 

DO_SPACE_BUCKET=**** // DO space name

DO_SPACE_DIRECTORY=**** // directory name from root without slash or trailing slash. This can also be skipped entirely from here as well as plugin config, if everything needs to be stored in root

DO_SPACE_CDN=**** // DO CDN endpoint without https or trailing slash, just the domain

config/plugins.js:

module.exports = ({ env }) => ({
  upload: {
    config: {
      provider: 'strapi-provider-upload-do',
      providerOptions: {
        key: env('DO_SPACE_ACCESS_KEY'),
        secret: env('DO_SPACE_SECRET_KEY'),
        endpoint: env('DO_SPACE_ENDPOINT'),
        space: env('DO_SPACE_BUCKET'),
        directory: env('DO_SPACE_DIRECTORY'),
        cdn: env('DO_SPACE_CDN'),
      },
    },
  },
});

config/middleware.js:

module.exports = ({ env }) => [
  'strapi::errors',
  'strapi::security',
  'strapi::cors',
  'strapi::poweredBy',
  'strapi::logger',
  'strapi::query',
  'strapi::body',
  'strapi::session',
  'strapi::favicon',
  'strapi::public',
  {
    name: 'strapi::security',
    config: {
      contentSecurityPolicy: {
        useDefaults: true,
        directives: {
          'connect-src': ["'self'", 'https:'],
          'img-src': [
            "'self'",
            'blob:',
            'data:',
            `${env('DO_SPACE_BUCKET')}.${env('DO_SPACE_ENDPOINT')}`,
            `${env('DO_SPACE_CDN')}`,
          ],
          'media-src': [
            "'self'",
            'blob:',
            'data:',
            `${env('DO_SPACE_BUCKET')}.${env('DO_SPACE_ENDPOINT')}`,
            `${env('DO_SPACE_CDN')}`,
          ],
          upgradeInsecureRequests: null,
        },
      },
    },
  },
];

Hello guys, I apologise for the late reply. I do not really check the forum that much so I may have missed any assistance or giving a solution that worked for me.For any future devs please do not use the strapi-provider-upload-do library if possible. Use the official library that’s maintained by the Strapi team AWS-S3 Link

The plugins configuration is

 upload: {
    config: {
      provider: "aws-s3",
      providerOptions: {
        s3Options: {
          credentials: {
            accessKeyId: process.env.DO_SPACE_ACCESS_KEY,
            secretAccessKey: process.env.DO_SPACE_SECRET_KEY,
          },
          endpoint: process.env.DO_SPACE_ENDPOINT, // aws-s3 v3 needs a prefixed https:// endpoint
          region: process.env.DO_SPACE_REGION,
          params: {
            Bucket: process.env.DO_SPACE_BUCKET,
          },
        },
      },
      actionOptions: {
        upload: {},
        uploadStream: {},
        delete: {},
      },
    },
  },

Am using Strapi version 4.17.0 as of this post. The Strapi library aws-s3 works like a charm. You can combine that library with prefix and use the cdn link from Digital Ocean spaces in Strapi to get awesome performance: Strapi Plugin Prefix