You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When creating a new certificate in the admin site, if I set CommonName to something with spaces, such as "A B" and leave the box "Include CommonName" ticked in the the SubjectAltName section, I get a parsing error (see below). While such a certificate may be awkward, it would still be best to catch the exception and avoid a server error.
Environment:
Request Method: POST
Request URL: http://127.0.0.1:8000/admin/django_ca/certificate/add/
Django Version: 3.1
Python Version: 3.7.3
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_object_actions',
'django_ca']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Traceback (most recent call last):
File "/var/local/cache/django_ca_test/python/lib/python3.7/site-packages/django_ca/profiles.py", line 310, in _update_san_from_cn
cn = parse_general_name(subject['CN'])
File "/var/local/cache/django_ca_test/python/lib/python3.7/site-packages/django_ca/utils.py", line 579, in parse_general_name
idna.encode(name)
File "/var/local/cache/django_ca_test/python/lib/python3.7/site-packages/idna/core.py", line 362, in encode
s = alabel(label)
File "/var/local/cache/django_ca_test/python/lib/python3.7/site-packages/idna/core.py", line 270, in alabel
ulabel(label)
File "/var/local/cache/django_ca_test/python/lib/python3.7/site-packages/idna/core.py", line 308, in ulabel
check_label(label)
File "/var/local/cache/django_ca_test/python/lib/python3.7/site-packages/idna/core.py", line 261, in check_label
raise InvalidCodepoint('Codepoint {0} at position {1} of {2} not allowed'.format(_unot(cp_value), pos+1, repr(label)))
During handling of the above exception (Codepoint U+0020 at position 2 of 'a b' not allowed), another exception occurred:
File "/var/local/cache/django_ca_test/python/lib/python3.7/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/var/local/cache/django_ca_test/python/lib/python3.7/site-packages/django/core/handlers/base.py", line 179, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/var/local/cache/django_ca_test/python/lib/python3.7/site-packages/django/contrib/admin/options.py", line 614, in wrapper
return self.admin_site.admin_view(view)(*args, **kwargs)
File "/var/local/cache/django_ca_test/python/lib/python3.7/site-packages/django/utils/decorators.py", line 130, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "/var/local/cache/django_ca_test/python/lib/python3.7/site-packages/django/views/decorators/cache.py", line 44, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File "/var/local/cache/django_ca_test/python/lib/python3.7/site-packages/django/contrib/admin/sites.py", line 233, in inner
return view(request, *args, **kwargs)
File "/var/local/cache/django_ca_test/python/lib/python3.7/site-packages/django_ca/admin.py", line 483, in add_view
return super(CertificateAdmin, self).add_view(request, form_url=form_url, extra_context=extra_context)
File "/var/local/cache/django_ca_test/python/lib/python3.7/site-packages/django/contrib/admin/options.py", line 1653, in add_view
return self.changeform_view(request, None, form_url, extra_context)
File "/var/local/cache/django_ca_test/python/lib/python3.7/site-packages/django/utils/decorators.py", line 43, in _wrapper
return bound_method(*args, **kwargs)
File "/var/local/cache/django_ca_test/python/lib/python3.7/site-packages/django/utils/decorators.py", line 130, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "/var/local/cache/django_ca_test/python/lib/python3.7/site-packages/django/contrib/admin/options.py", line 1534, in changeform_view
return self._changeform_view(request, object_id, form_url, extra_context)
File "/var/local/cache/django_ca_test/python/lib/python3.7/site-packages/django/contrib/admin/options.py", line 1580, in _changeform_view
self.save_model(request, new_object, form, not add)
File "/var/local/cache/django_ca_test/python/lib/python3.7/site-packages/django_ca/admin.py", line 655, in save_model
password=data['password'], extensions=extensions)
File "/var/local/cache/django_ca_test/python/lib/python3.7/site-packages/django_ca/profiles.py", line 227, in create_cert
self._update_san_from_cn(cn_in_san, subject=cert_subject, extensions=cert_extensions)
File "/var/local/cache/django_ca_test/python/lib/python3.7/site-packages/django_ca/profiles.py", line 312, in _update_san_from_cn
raise ValueError('%s: Could not parse CommonName as subjectAlternativeName.' % subject['CN'])
Exception Type: ValueError at /admin/django_ca/certificate/add/
Exception Value: A B: Could not parse CommonName as subjectAlternativeName.
The text was updated successfully, but these errors were encountered:
Hi. Great package!
When creating a new certificate in the admin site, if I set CommonName to something with spaces, such as "A B" and leave the box "Include CommonName" ticked in the the SubjectAltName section, I get a parsing error (see below). While such a certificate may be awkward, it would still be best to catch the exception and avoid a server error.
The text was updated successfully, but these errors were encountered: