Giter Club home page Giter Club logo

Comments (6)

noelmartinon avatar noelmartinon commented on July 22, 2024 1

Hello, need to be completed :
With django-ca 1.23.0, issue if 'USE_TZ = True' when signing cert. For example:

python manage.py sign_cert --ca=Intermediate --csr=example.csr --out=example.pem --client --alt=hello.example.org'''

File "/srv/venv/lib/python3.10/site-packages/django_ca/management/base.py", line 269, in test_options
    if ca.expires < expires:
TypeError: can't compare offset-naive and offset-aware datetimes

Resolved with:

--- a/ca/django_ca/management/base.py	2023-04-02 10:07:46.267345675 -0400
+++ b/ca/django_ca/management/base.py	2023-04-02 10:06:31.622540000 -0400
@@ -31,7 +31,7 @@
 from django_ca.management import actions, mixins
 from django_ca.models import CertificateAuthority
 from django_ca.profiles import Profile
-from django_ca.utils import NAME_OID_MAPPINGS
+from django_ca.utils import NAME_OID_MAPPINGS, make_naive
 
 
 class BinaryOutputWrapper(OutputWrapper):
@@ -265,6 +265,7 @@
         """Additional tests for validity of some options."""
 
         expires = profile.get_expires(expires)
+        ca.expires = make_naive(ca.expires)

 
         if ca.expires < expires:
             max_days = (ca.expires - timezone.now()).days

from django-ca.

mathiasertl avatar mathiasertl commented on July 22, 2024

Thanks for your Bugreport! I can reproduce the issue and I'm working on a fix.

In the mean time, this patch also fixes the issue:

--- a/ca/django_ca/utils.py
+++ b/ca/django_ca/utils.py
@@ -50,6 +50,7 @@ from cryptography.x509.oid import NameOID
 
 from django.core.files.storage import get_storage_class
 from django.core.validators import URLValidator
+from django.utils import timezone as tz
 from django.utils.translation import gettext_lazy as _
 
 from . import ca_settings
@@ -1162,6 +1177,8 @@ def get_cert_builder(expires: datetime, serial: Optional[int] = None) -> x509.Ce
     if serial is None:
         serial = x509.random_serial_number()
 
+    if tz.is_aware(expires):
+        expires = tz.make_naive(expires)
     if expires <= now:
         raise ValueError("expires must be in the future")
 

from django-ca.

jacekjaros avatar jacekjaros commented on July 22, 2024

hi @mathiasertl

after applying patch my setup are working fine, thanks for quick response.

from django-ca.

mathiasertl avatar mathiasertl commented on July 22, 2024

hi @jacekjaros,

Fixed in c8ed135 (and forgot to mention that in the commit message). This will be in 1.20, for which I'm actually just finishing documentation updates.

kr, Mat

from django-ca.

mathiasertl avatar mathiasertl commented on July 22, 2024

@noelmartinon Thanks for the report, and I've re-opened the issue!

Please note that in general maintainers won't notice comments on closed issues, I spotted this by chance. It's usually better to open a new issue.

from django-ca.

mathiasertl avatar mathiasertl commented on July 22, 2024

@noelmartinon I believe the issue is fixed in the current main branch. You you cloned the source from git, you're welcome to try it out,otherwise the next release (mid May) will include the fix!

If you have further feedback, please feel free to comment!

from django-ca.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.