php / php/php-src

SSL context options for in memory cert and pk

Đang mở
#7,797 18 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Category: Streams Extension: openssl Feature Status: Verified
Ngôn ngữ chính
C
Star
40.4k
Fork
8.2k
Merge trung bình
2 ngày 13 giờ
Pull request đã merge (30 ngày)
96

Mô tả

Description

It is dangerous to store certificates and privateKeys (without a password) on the disk. Unfortunately, this is needed to load the * .p12 file into stream_context_create.

Please, add the option to set certificates and privateKeys from string content or at least from Data URLs, instead the file path only.

// Using string content
// --------------------

openssl_pkcs12_read(file_get_contents('cert.p12'),$certificates,'pass');

$stream_context = stream_context_create(
[ 'ssl' => [ 'local_cert' => $certificates['cert'],
             'local_pk'   => $certificates['pkey']
           ]
]);
// Using Data URLs
// ---------------

openssl_pkcs12_read(file_get_contents('cert.p12'),$certificates,'pass');

$stream_context = stream_context_create(
[ 'ssl' => [ 'local_cert' => 'data:,'.$certificates['cert'],
             'local_pk'   => 'data:,'.$certificates['pkey']
           ]
]);
// Hack: temp files
// ----------------

openssl_pkcs12_read(file_get_contents('cert.p12'),$certificates,'pass');

file_put_contents('cert.temp',$certificates['cert']);
file_put_contents('pkey.temp',$certificates['pkey']);

$stream_context = stream_context_create(
[ 'ssl' => [ 'local_cert' => 'cert.temp',
             'local_pk'   => 'pkey.temp'
           ]
]);

Expected result: Reading certificates and privateKeys without temp files.
Actual result: Reading certificates and privateKeys only with temp files.

PHP Version

PHP 8.1.1

Operating System

All

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu với các tùy chọn SSL của stream_context_create, đặc biệt là local_cert và local_pk, rồi so sánh cách xử lý đường dẫn tệp hiện tại của chúng với đầu ra openssl_pkcs12_read được hiển thị ở đây. Xác định dạng biểu diễn được hỗ trợ và bổ sung phạm vi kiểm thử chứng minh việc tải chứng chỉ và khóa riêng mà không cần tệp tạm thời; hoàn thành khi ví dụ được cung cấp hoạt động trên mọi nền tảng.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
c, php
Lĩnh vực
networking, security
Loại issue
Tính năng
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.