|
|
LXXII. OpenSSL functionsIntroduction
This module uses the functions of for generation and verification
of signatures and for sealing (encrypting) and opening (decrypting)
data. OpenSSL offers many features that this module currently doesn't
support. Some of these may be added in the future.
Requirements
In order to use the OpenSSL functions you need to install the package.
PHP-4.0.4pl1 requires OpenSSL >= 0.9.6, but PHP-4.0.5 and greater
will also work with OpenSSL >= 0.9.5.
Installation
To use PHP's OpenSSL support you must also compile PHP --with-openssl[=DIR].
Note to Win32 Users:
In order to enable this module on a Windows environment, you must copy
libeay32.dll from the DLL folder of the PHP/Win32 binary
package to the SYSTEM32 folder of your windows machine. (Ex: C:\WINNT\SYSTEM32
or C:\WINDOWS\SYSTEM32)
Additionally, if you are planning to use the key generation and certificate
signing functions, you will need to install a valid
openssl.cnf on your system. As of PHP 4.3.0, we
include a sample configuration file in the openssl of
our win32 binary distribution. If you are using PHP 4.2.0 or later and are
missing the file, you can obtain it from or by downloading the PHP 4.3.0 release and using
the configuration file from there.
Note to Win32 Users:
PHP will search for the openssl.cnf using the
following logic:
the OPENSSL_CONF environmental variable, if
set, will be used as the path (including filename) of the configuration
file.
the SSLEAY_CONF environmental variable, if
set, will be used as the path (including filename) of the configuration
file.
The file openssl.cnf will be assumed to be
found in the default certificate area, as configured at the time that
the openssl DLL was compiled. This is usually means that the default
filename is c:\usr\local\ssl\openssl.cnf.
In your installation, you need to decide whether to install the
configuration file at c:\usr\local\ssl\openssl.cnf or
whether to install it someplace else and use environmental variables
(possibly on a per-virtual-host basis) to locate the configuration file.
Note that it is possible to override the default path from the script using
the configargs of the functions that require a
configuration file.
Runtime ConfigurationThis extension has no configuration directives defined in php.ini. Key/Certificate parameters
Quite a few of the openssl functions require a key or a certificate
parameter. PHP 4.0.5 and earlier have to use a key or certificate
resource returned by one of the openssl_get_xxx functions.
Later versions may use one of the following methods:
Certificates
An X.509 resource returned from
openssl_x509_read()
A string having the format
file://path/to/cert.pem; the named file must
contain a PEM encoded certificate
A string containing the content of a certificate, PEM encoded
Public/Private Keys
A key resource returned from
openssl_get_publickey() or
openssl_get_privatekey()
For public keys only: an X.509 resource A string having the format
file://path/to/file.pem - the named file must
contain a PEM encoded certificate/private key (it may contain both)
A string containing the content of a certificate/key, PEM encoded
For private keys, you may also use the syntax
array($key, $passphrase) where $key represents a
key specified using the file:// or textual content notation above, and
$passphrase represents a string containing the passphrase for that
private key
Certificate Verification
When calling a function that will verify a signature/certificate, the
cainfo parameter is an array containing file and
directory names that specify the locations of trusted CA files. If a
directory is specified, then it must be a correctly formed hashed
directory as the openssl command would use.
Predefined Constants
The constants below are defined by this extension, and
will only be available when the extension has either
been compiled into PHP or dynamically loaded at runtime.
PKCS7 Flags/Constants
The S/MIME functions make use of flags which are specified using a
bitfield which can include one or more of the following values:
표 1. PKCS7 CONSTANTS Constant | Description |
---|
PKCS7_TEXT | adds text/plain content type headers to encrypted/signed
message. If decrypting or verifying, it strips those headers from
the output - if the decrypted or verified message is not of MIME type
text/plain then an error will occur. | PKCS7_BINARY | normally the input message is converted to "canonical" format
which is effectively using CR and LF as end of line: as required by
the S/MIME specification. When this options is present, no
translation occurs. This is useful when handling binary data which
may not be in MIME format. | PKCS7_NOINTERN | when verifying a message, certificates (if
any) included in the message are normally searched for the
signing certificate. With this option only the
certificates specified in the extracerts
parameter of openssl_pkcs7_verify() are
used. The supplied certificates can still be used as
untrusted CAs however.
| PKCS7_NOVERIFY | do not verify the signers certificate of a signed
message. | PKCS7_NOCHAIN | do not chain verification of signers certificates: that is
don't use the certificates in the signed message as untrusted CAs.
| PKCS7_NOCERTS | when signing a message the signer's certificate is normally
included - with this option it is excluded. This will reduce the
size of the signed message but the verifier must have a copy of the
signers certificate available locally (passed using the
extracerts to
openssl_pkcs7_verify() for example.
| PKCS7_NOATTR | normally when a message is signed, a set of attributes are
included which include the signing time and the supported symmetric
algorithms. With this option they are not included.
| PKCS7_DETACHED | When signing a message, use cleartext signing with the MIME
type multipart/signed. This is the default if the
flags parameter to
openssl_pkcs7_sign() if you do not specify any
flags. If you turn this option off, the message will be signed using
opaque signing, which is more resistant to translation by mail relays
but cannot be read by mail agents that do not support S/MIME. | PKCS7_NOSIGS | Don't try and verify the signatures on a message |
참고: These constants were added in 4.0.6.
User Contributed Notes OpenSSL functions |
add a note |
webmaster at jukkis dot net
06-Apr-2001 10:19 |
|
I had a hard time to make OpenSSL extension to load on Win98+Apache
1.3.17+Php4.0.4pl1.
Always complained about missing
extension.
Eventually I found this page:
and
there was the magic: One seems to need the files "libeay32.dll"
and "ssleay32.dll" in system32 directory.
You can get
them from
download
an apache .zip file, for example
"Apache_1.3.19-Mod_SSL_2.8.2-OpenSSL_0.9.6-WIN32.zip", extract
it, and copy the mentioned files from that Apache directory.
At
least phpinfo() says OpenSSL as loaded extension. Now I can start to
play with it :)
-jukkis
-www.jukkis.net
|
|
buzz77 at gmx dot net
02-Jun-2001 08:05 |
|
PHP 4.0.5 and OpenSSL
if you got an error message where php
complains about missing dlls, copy all files from /php/dll directory to
your windows/system(32) directory.
If it still can't load because the
MSVCR70.DLL is missing (not provided with the release found on this page),
go to this link, download it and place it in
windows/system(32).
|
|
alistair at lgeezer dot net
30-Jan-2003 03:37 |
|
Oops! That's not quite the entire truth. 4.3.0 and 0.9.7 do work together,
<= 4.2.1 and 0.9.7 don't. Sorry about that :-)
|
|
adolfo dot garcia at NOSPAM dot uservers dot net
07-May-2003 09:59 |
|
If you are having problems compiling php with openssl under redhat 9,
because it complains about the kerberos libraries and include headers, try
the following:
1. Make sure you have the kerb5-devel and krb5-libs
rpms installed. 2. Symlink the following files as follows:
ln
-s /usr/kerberos/include/com_err.h /usr/include/ ln -s
/usr/kerberos/include/profile.h /usr/include/ ln -s
/usr/kerberos/include/krb5.h /usr/include/
Then configure
--with-kerberos and --with-openssl and it should work.
This is the
error that appears whe running make (included so that the search engine
can find it):
/usr/include/openssl/kssl.h:72:18: krb5.h: No such
file or directory
|
|
add a note |
| |