SSL context options for in memory cert and pk
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 40.4k
- Forks
- 8.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 96
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the stream_context_create SSL options, especially local_cert and local_pk, and compare their current file-path handling with the openssl_pkcs12_read output shown here. Determine the supported representation and add coverage demonstrating certificate and private-key loading without temporary files; done means the supplied example works on all platforms.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, php
- Domain
- networking, security
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100