OpenSSL engine: leaf certificates get O=Internet Widgits Pty Ltd, ST=Some-State from system openssl.cnf

オープン 初心者向け
#9,366 コメント 0 件 リアクション 0 件 担当者 1 名 GitHub で見る

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

@vitormattos がすでに取り組んでいます。

2026年11月12日 から。

  • #9430 @vitormattos による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
php
領域
backend, security

調査の方向性

OpenSslHandler::generateCertificate()の、OpenSslHandler.phpの182行目にあるleaf CSR作成箇所を読み、次にgenerateLeafConfig()と、比較のためにルートCSRのオプションを調べてください。提供されたPHPスニペットで再現するか、指定されたNextcloudイメージでleaf証明書を生成してください。leaf証明書のsubjectに、LibreSignが設定または継承するフィールドだけが含まれ、システムのOpenSSLデフォルト値が含まれない状態になれば完了です。

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

説明

Describe the bug

Signer certificates created with the OpenSSL engine contain O=Internet Widgits Pty Ltd and ST=Some-State, although the root certificate has neither field: the leaf CSR is created without a config, so openssl_csr_new fills missing DN fields with the *_default values of the system openssl.cnf.

To reproduce
  1. Official nextcloud:35.0.2-apache image (Debian 13), certificate engine OpenSSL.
  2. Generate the root certificate with only CN, C and L: occ libresign:configure:openssl --cn=… --c=DE --l=…
  3. Let a user create their signature certificate and sign a PDF.
  4. pdfsig signed.pdf shows:
    Signer full Distinguished Name: O=Internet Widgits Pty Ltd,ST=Some-State,CN=…,UID=account:…,OU=libresign-ca-id:…,L=…,C=DE
    while the root subject is only C=DE, L=…, OU=libresign-ca-id:…, CN=….

Minimal PHP reproduction inside the container:

$k = openssl_pkey_new(['private_key_bits' => 2048]);
$c = openssl_csr_new(['commonName' => 'x', 'countryName' => 'DE'], $k, ['digest_alg' => 'sha256']);
print_r(openssl_csr_get_subject($c)); // CN, C, ST => Some-State, O => Internet Widgits Pty Ltd

Cause: in OpenSslHandler::generateCertificate() the CSR is created as createCsr($this->getCsrNames(), $privateKey, ['digest_alg' => 'sha256']), without a config option. PHP then falls back to the system openssl.cnf (Debian: stateOrProvinceName_default = Some-State, 0.organizationName_default = Internet Widgits Pty Ltd) and adds those defaults for every DN field not passed. The root CSR passes a config file via getRootCsrOptions() and is not affected.

Expected behavior

The leaf DN contains only the fields LibreSign sets (CN, UID and the fields inherited from the root); passing a config (e.g. the leaf config from generateLeafConfig()) to createCsr would fix it.

Screenshots

No response

Operational System

Docker, official nextcloud:35.0.2-apache image (Debian 13), on Kubernetes

Browser Type and Version

Not browser-related (server-side certificate generation)

Libresign Version

15.0.12 (still present on main, OpenSslHandler.php line 182)

Nextcloud Server Version

35.0.2

Logs from Nextcloud Server

No log entries: certificate generation succeeds, only the subject is wrong.

Logs from Developers tools

No response

Additional context

Workaround: set OPENSSL_CONF for the PHP processes to a file that includes the system config and points [req] distinguished_name to an empty section:

.include /usr/lib/ssl/openssl.cnf
[ req ]
distinguished_name = req_dn_libresign
[ req_dn_libresign ]

With it, the CSR contains only the passed fields; TLS from PHP keeps working. Certificates issued before keep the placeholder until the user recreates their certificate.

主要言語
PHP
スター
844
フォーク
176
平均マージ
13時間 46分
マージ済み PR(30日)
299

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

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

LibreSign/libresign のほかの issue

LibreSign/libresign の issue をすべて見る

似ている issue

PHP の issue をもっと見る

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

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