PeculiarVentures / x509

@peculiar/x509 is an easy to use TypeScript/Javascript library based on @peculiar/asn1-schema that makes generating X.509 Certificates and Certificate Requests as well as validating certificate chains easy
https://peculiarventures.github.io/x509/
MIT License
78 stars 10 forks source link

Textual representation #48

Closed microshine closed 1 year ago

microshine commented 1 year ago

Features

Fixes

Certificate

Certificate:
  Data:
    Version: v3 (2)
    Serial Number: 
      01 02 03 04 05 06 07 08  09 0a 0b 0c 0d 0e 0f 00
    Signature Algorithm: ecdsaWithSHA256
    Issuer: CN=Intermediate CA, O=Some organization
    Validity:
      Not Before: Wed, 09 Nov 2022 12:13:14 GMT
      Not After: Mon, 09 Nov 2122 12:13:14 GMT
    Subject: CN=Test, O=Some organization, E=some@email.com
    Subject Public Key Info:
      Algorithm: ecPublicKey
        Named Curve: P-256
      EC Point: 
        04 22 75 ea d5 20 2a f0  5d 42 b5 9e 11 c3 68 5c
        30 e0 f1 e4 93 a7 a2 87  42 96 cd b8 80 07 13 46
        7c 58 8f 99 b4 f4 1c ec  1f 71 fa 14 80 9d 6d 16
        f5 a9 f8 fe 6c 6c 4b b2  05 f4 62 1b f2 c6 41 65
        2b
    Extensions:
      Key Usage: critical
        digitalSignature, nonRepudiation
      Basic Constraints: critical
      Certificate Policies:
        Policy: 1.2.3.4.5.6
        Policy: 1.2.3.4.5.6.7
      Extended Key Usages:
        TLS WWW server authentication, TLS WWW client authentication
      Subject Key Identifier:
        d2 4f ca 9c 59 9f bd c6  8c 44 d4 ce 93 28 be 54
        cc da b0 ac
      Authority Key Identifier:
        Authority Issuer:
          DNS: some.com
          Email: some@email.com
        Authority Serial Number: 
          01 02 03 04 05 06 07 08
      Subject Alternative Name:
        DNS: some.com
        Email: some@email.com
        Email: microshine@mail.ru
        GUID: 7fb11cd1-823e-4eb3-936b-ebb82ad5b876
        IP: 192.168.1.1
        ID: 1.2.3.4.5.6
        UPN: microshine@domain.com
        URL: https://some.com
      1.2.3.4.5.6:
        02 03 01 00 01
  Signature:
    Algorithm: ecdsaWithSHA256
    30 45 02 20 31 fe 7f 24  df 2f 7c 49 63 69 51 fe
    21 87 df 3e d8 93 77 65  5e c9 f4 42 64 b2 bd 34
    6e 9b ec 43 02 21 00 fd  38 e0 78 e1 85 a7 ae 1f
    b0 52 18 4d 2a 41 b6 f3  32 dd 3b 42 d7 04 fc d4
    eb 0a 96 68 da c5 c4

PKCS#10 certificate request

PKCS#10 Certificate Request:
  Data:
    Version: v1 (0)
    Subject: CN=Test
    Subject Public Key Info:
      Algorithm: ecPublicKey
        Named Curve: P-256
      EC Point: 
        04 7d 9f a2 1c c5 aa 07  e5 fb 41 cb 35 31 49 55
        42 d0 ea c8 c7 82 31 73  e7 6d a2 98 d8 fb 3d 3f
        49 5c de a4 41 1b dc b1  a0 1e 65 94 e0 7f c6 d9
        7d 4f fc 13 09 cd 62 a3  ae 19 7d 0f bf 79 a6 ae
        c0
    Attributes:
      Challenge Password: ABCDEF
      Extensions:
        Basic Constraints: critical
  Signature:
    Algorithm: ecdsaWithSHA256
    30 44 02 20 5c c9 0c 3e  1a d1 25 3f ad 3c f0 cc
    47 02 4b 26 a1 ec 97 3b  1c 4f c3 07 b6 f7 da d0
    68 37 ab a9 02 20 3b bd  66 f4 7c 69 df 77 3c 8e
    59 41 9d 86 ed 3c 52 fe  64 51 60 58 1c 82 30 b6
    94 21 5f 92 bf 29

PKCS#7 certificate collection

Content Type: Signed Data
  Content:
    Version: v1 (1)
    Certificates:
      Certificate:
        Data:
          Version: v3 (2)
          Serial Number: 
            01 02 03 04 05 06 07 08  09 0a 0b 0c 0d 0e 0f 00
          Signature Algorithm: ecdsaWithSHA256
          Issuer: CN=Intermediate CA, O=Some organization
          Validity:
            Not Before: Wed, 09 Nov 2022 12:13:14 GMT
            Not After: Mon, 09 Nov 2122 12:13:14 GMT
          Subject: CN=Test, O=Some organization, E=some@email.com
          Subject Public Key Info:
            Algorithm: ecPublicKey
              Named Curve: P-256
            EC Point: 
              04 9e 28 22 72 52 5d d4  b0 11 c0 46 fc 8b 8a d0
              cd 6b 29 8c ea 96 f2 98  aa 07 81 2d 03 a9 e1 9d
              60 c3 00 d8 4b 9b 70 0a  3a f4 36 44 0a 7f 09 d8
              3c b4 a0 52 49 8c 6f e9  71 35 19 ef 0d 1e c8 00
              d7
          Extensions:
            Key Usages: critical
              digitalSignature, nonRepudiation
        Signature:
          Algorithm: ecdsaWithSHA256
          30 45 02 20 6c 2d 65 93  f3 b3 2d 45 a7 33 20 74
          1d cb 9b 39 87 7d a8 33  ab ba b1 a3 24 13 e1 06
          3c 8f 46 73 02 21 00 d1  2d 7b 36 ce 43 19 f0 d3
          12 e3 e2 89 52 11 c1 05  2b 66 79 85 ca 06 fd 5a
          67 9d 3c ae 00 0b 1d
      Certificate:
        Data:
          Version: v3 (2)
          Serial Number: 
            01 02 03 04 05 06 07 08  09 0a 0b 0c 0d 0e 0f 00
          Signature Algorithm: ecdsaWithSHA256
          Issuer: CN=Intermediate CA, O=Some organization
          Validity:
            Not Before: Wed, 09 Nov 2022 12:13:14 GMT
            Not After: Mon, 09 Nov 2122 12:13:14 GMT
          Subject: CN=Test, O=Some organization, E=some@email.com
          Subject Public Key Info:
            Algorithm: ecPublicKey
              Named Curve: P-256
            EC Point: 
              04 9e 28 22 72 52 5d d4  b0 11 c0 46 fc 8b 8a d0
              cd 6b 29 8c ea 96 f2 98  aa 07 81 2d 03 a9 e1 9d
              60 c3 00 d8 4b 9b 70 0a  3a f4 36 44 0a 7f 09 d8
              3c b4 a0 52 49 8c 6f e9  71 35 19 ef 0d 1e c8 00
              d7
          Extensions:
            Key Usages: critical
              digitalSignature, nonRepudiation
        Signature:
          Algorithm: ecdsaWithSHA256
          30 45 02 20 6c 2d 65 93  f3 b3 2d 45 a7 33 20 74
          1d cb 9b 39 87 7d a8 33  ab ba b1 a3 24 13 e1 06
          3c 8f 46 73 02 21 00 d1  2d 7b 36 ce 43 19 f0 d3
          12 e3 e2 89 52 11 c1 05  2b 66 79 85 ca 06 fd 5a
          67 9d 3c ae 00 0b 1d