Error: Only 8, 16, 24, or 32 bits supported: 608 in certificationRequestFromPem

オープン
#1,097 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
javascript

調査の方向性

Reproduce the StackBlitz example and compare certificationRequestToPem with certificationRequestFromPem, focusing on the non-ASCII “№” subject values and the reported 608-bit error. Trace the PEM and ASN.1 decoding path from certificationRequestFromPem. Done means the shown CSR round-trips successfully without the error.

索引モデルが issue の本文から書いたものです。

説明

Hello!

When I create a certificate request, convert it to PEM format, and then decode it back, I get an error: Error: Only 8, 16, 24, or 32 bits supported: 608.

I'm guessing the problem is that there is a "№" character in my certificate parameters, which I think is causing problems when converting to base64 or vice versa.

Can I somehow avoid this problem?

Example:

https://stackblitz.com/edit/vitejs-vite-dmjz3f?file=main.js

    const keys = pki.rsa.generateKeyPair(2048);
    const csr = pki.createCertificationRequest();

    const subject = [
        {
            name: 'commonName',
            value: '"ITEM №1"',
        },
        {
            name: 'countryName',
            value: 'RU',
        },
        {
            name: 'localityName',
            value: 'G SAMARA',
        },
        {
            name: 'organizationName',
            value: '"ITEM №1"',
        },
        {
            name: 'stateOrProvinceName',
            value: 'SAMARSKAIA',
        },
        {
            name: 'emailAddress',
            value: '[email protected]',
        },
    ];

    const attributes = [
        {
            name: 'extensionRequest',
            extensions: [
                {
                    name: 'keyUsage',
                    digitalSignature: true,
                    nonRepudiation: true,
                    keyEncipherment: true,
                    dataEncipherment: true,
                    keyAgreement: true,
                },
                {
                    name: 'extKeyUsage',
                    clientAuth: true,
                },
            ],
        },
    ];

    csr.publicKey = keys.publicKey;
    csr.setSubject(subject);
    csr.setAttributes(attributes);
    csr.sign(keys.privateKey);

    const rsaPrivateKey = pki.privateKeyToAsn1(keys.privateKey);
    const privateKeyInfo = pki.wrapRsaPrivateKey(rsaPrivateKey);

    const output = {
        privateKey: pki.privateKeyInfoToPem(privateKeyInfo),
        publicKey: pki.publicKeyToPem(keys.publicKey),
        csrKey: pki.certificationRequestToPem(csr), // it's OK
    }

   // decode it
   pki.certificationRequestFromPem(output.csrKey) // Error

主要言語
JavaScript
スター
5.4k
フォーク
874
平均マージ
3分
マージ済み PR(30日)
6

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

digitalbazaar/forge のほかの issue

digitalbazaar/forge の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。