[PATCH] Preliminary OpenSSL Changes (PEM)

php.internals

Brandon Fosdick

20 years ago
I'm not finished yet, but I'm at a decent check point, so I thought I'd send out what I've done so far with the hope of getting some feedback. The attached files contain the patches and new files (wrt 5.1.4) for implementing import and export of PEM strings for both public and private keys using an OO interface. BTW, I know the code doesn't conform to the CS very well, I plan to run everything through astyle at the very end. One of my initial goals was to avoid modifying existing code as much as possible to avoid introducing new breakage. In hindsight that might have been more trouble than it was worth because I ended up doing a lot more than I had originally planned. But it was a good learning experience. I decided on an OO interface because it seemed like it could be most easily accomplished w/o touching existing code. At present the new interface adds two classes, described below. I wasn't sure what to name them, so feel free to offer suggestions. class PrivateKey constructor( [string pem [, string passphrase]] ) constructor( [array configargs]] ) string pem( [ string passphrase [, encrypt_key]] ) PublicKey public() class PublicKey constructor(string pem) string pem() I'm not sure about the second constructor for PrivateKey, since it really only needs two of the configarg values. I'm thinking about having it take just those two as separate arguments. Most of the changes are in the new files. In openssl.c I added a call to init_object() in the MINIT function and moved struct php_x509_request to openssl.h so I could use it elsewhere. I also made a few functions non-static so they could be called from the other files. From here I think I might as well add an object for certificates (X509, X509Certificate, Certificate...?) and then I'll add PKCS12 support. Thoughts, suggestions? Problems?

Wez Furlong

20 years ago
Probably the biggest problem is that it requires C++. We mentioned to you that C++ was something we avoided in PHP because it tends to create more problems than it's worth, particularly so in something that is part of the core distribution. Can you write it in C instead? --Wez. On 5/12/06, Brandon Fosdick <bfoz@bfoz.net> wrote:

Brandon Fosdick

20 years ago
Wez Furlong wrote:
> Probably the biggest problem is that it requires C++. > We mentioned to you that C++ was something we avoided in PHP because > it tends to create more problems than it's worth, particularly so in > something that is part of the core distribution.
I must have missed that. Although I do remember asking about it and not getting a response. Don't see anything in the archives either.
> Can you write it in C instead?
I could, but I've finished the functionality I need so now it's hard to justify the time to do a complete rewrite. deadlines, deadlines... I don't see a crypto package in PECL and none of what I've done is strictly SSL related, so would it be acceptable if I fork and submit a module to PECL? Assuming I find the time.