Reputation: 1370
Here is the application hosted on heroku + aws s3 used for storing only media files.
When user upload's a images the error occures .
CertificateError at /create/
hostname 'shuboy.media.s3.amazonaws.com' doesn't match either of '*.s3.amazonaws.com', 's3.amazonaws.com'
Request Method: POST
Request URL: http://shuboy2015.herokuapp.com/create/
Django Version: 1.9.6
Exception Type: CertificateError
Exception Value:
hostname 'shuboy.media.s3.amazonaws.com' doesn't match either of '*.s3.amazonaws.com', 's3.amazonaws.com'
Exception Location: /app/.heroku/python/lib/python2.7/ssl.py in match_hostname, line 271
Python Executable: /app/.heroku/python/bin/python
Python Version: 2.7.10
Python Path:
['/app',
'/app/.heroku/python/bin',
'/app/.heroku/python/lib/python2.7/site-packages/setuptools-20.4-py2.7.egg',
'/app/.heroku/python/lib/python2.7/site-packages/pip-8.1.1-py2.7.egg',
'/app',
'/app/.heroku/python/lib/python27.zip',
'/app/.heroku/python/lib/python2.7',
'/app/.heroku/python/lib/python2.7/plat-linux2',
'/app/.heroku/python/lib/python2.7/lib-tk',
'/app/.heroku/python/lib/python2.7/lib-old',
'/app/.heroku/python/lib/python2.7/lib-dynload',
'/app/.heroku/python/lib/python2.7/site-packages']
Server time: Tue, 7 Jun 2016 20:54:31 +0000
In settings.py file , I only want to store media files there no static files.
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
AWS_S3_SECURE_URLS = False
AWS_QUERYSTRING_AUTH = False
AWS_S3_ACCESS_KEY_ID = '*******'
AWS_S3_SECRET_ACCESS_KEY = '******'
AWS_STORAGE_BUCKET_NAME ='shuboy.media'
AWS_S3_CUSTOM_DOMAIN = '%s.s3.amazonaws.com' % AWS_STORAGE_BUCKET_NAME
STATIC_URL = '/static/'
MEDIA_URL = 'https://%s/media/' % AWS_S3_CUSTOM_DOMAIN
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "appname/static"),
]
STATIC_ROOT = os.path.join(BASE_DIR, "STATIC_CDN")
MEDIA_ROOT = '%s.s3.amazonaws.com/media/' % AWS_STORAGE_BUCKET_NAME
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
If anybody tell me why this error is occurring and how can I solve this issue ? Any further suggestions will be appreciable .
Upvotes: 1
Views: 1892
Reputation: 4003
The boto package doesn't fully support S3 buckets with dots in the name, because of SSL certificate scope.
Either create and use a new bucket without a dot, like "shuboymedia", or add this monkey patch in your settings:
import ssl
if hasattr(ssl, '_create_unverified_context'):
ssl._create_default_https_context = ssl._create_unverified_context
Upvotes: 4
Reputation: 14533
The above error is happening because your bucket name has a "." in it.
The work around for this issue is go to ~/.boto
configuration file search for https_validate_certificates
and set it to False
it will work.
Or remove the "." from your bucket name for it to work correctly.
Upvotes: 4