Library to interact with the OpenSSL library and implement S/MIME.
Copyright 2002-2012 Horde LLC (http://www.horde.org/)
See the enclosed file COPYING for license information (LGPL). If you
did not receive this file, see http://www.horde.org/licenses/lgpl21.
Methods summary
public
boolean
|
#
verifyPassphrase( string $private_key, string $passphrase )
Verify a passphrase for a given private key.
Verify a passphrase for a given private key.
Parameters
- $private_key
- The user's private key.
- $passphrase
- The user's passphrase.
Returns
boolean Returns true on valid passphrase, false on invalid
passphrase.
|
public
string
|
#
encrypt( string $text, array $params = array() )
Encrypt text using S/MIME.
Encrypt text using S/MIME.
Parameters
- $text
- The text to be encrypted.
- $params
- <p>The parameters needed for encryption.
See the individual _encrypt*() functions for
the parameter requirements.</p>
Returns
string The encrypted message.
Throws
Overrides
|
public
string
|
#
decrypt( string $text, array $params = array() )
Decrypt text via S/MIME.
Parameters
- $text
- The text to be smime decrypted.
- $params
- <p>The parameters needed for decryption.
See the individual _decrypt*() functions for
the parameter requirements.</p>
Returns
string The decrypted message.
Throws
Overrides
|
public
stdClass
|
#
verify( string $text, mixed $certs )
Verify a signature using via S/MIME.
Verify a signature using via S/MIME.
Parameters
- $text
- The multipart/signed data to be verified.
- $certs
- Either a single or array of root certificates.
Returns
stdClass Object with the following elements:
cert - (string) The certificate of the signer stored in the message (in
PEM format).
email - (string) The email of the signing person.
msg - (string) Status string.
verify - (boolean) True if certificate was verified.
Throws
|
public
Horde_Mime_Part
|
#
signMIMEPart( Horde_Mime_Part $mime_part, array $params )
Sign a MIME part using S/MIME. This produces S/MIME Version 3.2
compatible data (see RFC 5751 [3.4]).
Sign a MIME part using S/MIME. This produces S/MIME Version 3.2
compatible data (see RFC 5751 [3.4]).
Parameters
- $mime_part
- The object to sign.
- $params
- The parameters required for signing.
Returns
Horde_Mime_Part A signed MIME part object.
Throws
|
public
Horde_Mime_Part
|
#
encryptMIMEPart( Horde_Mime_Part $mime_part, array $params = array() )
Encrypt a MIME part using S/MIME. This produces S/MIME Version 3.2
compatible data (see RFC 5751 [3.3]).
Encrypt a MIME part using S/MIME. This produces S/MIME Version 3.2
compatible data (see RFC 5751 [3.3]).
Parameters
- $mime_part
- The object to encrypt.
- $params
- <p>The parameters required for
encryption.</p>
Returns
Horde_Mime_Part An encrypted MIME part object.
Throws
|
public
mixed
|
#
signAndEncryptMIMEPart( Horde_Mime_Part $mime_part, array $sign_params = array(), array $encrypt_params = array() )
Sign and Encrypt a MIME part using S/MIME.
Sign and Encrypt a MIME part using S/MIME.
Parameters
- $mime_part
- The object to sign and encrypt.
- $sign_params
- <p>The parameters required for
signing. @see _encryptSignature().</p>
- $encrypt_params
- <p>The parameters required for
encryption.</p>
Returns
mixed A Horde_Mime_Part object that is signed and encrypted.
Throws
See
_encryptMessage().
|
public
string
|
#
certToHTML( string $cert )
Convert a PEM format certificate to readable HTML version.
Convert a PEM format certificate to readable HTML version.
Parameters
- $cert
- PEM format certificate.
Returns
string HTML detailing the certificate.
|
public
array
|
#
parseCert( string $cert )
Extract the contents of a PEM format certificate to an array.
Extract the contents of a PEM format certificate to an array.
Parameters
- $cert
- PEM format certificate.
Returns
array All extractable information about the certificate.
|
public
|
#
checkForOpenSSL( )
Check for the presence of the OpenSSL extension to PHP.
Check for the presence of the OpenSSL extension to PHP.
Throws
|
public
mixed
|
#
getEmailFromKey( string $key )
Extract the email address from a public key.
Extract the email address from a public key.
Parameters
Returns
mixed Returns the first email address found, or null if
there are none.
|
public
stdClass
|
#
parsePKCS12Data( string $pkcs12, array $params )
Convert a PKCS 12 encrypted certificate package into a private key,
public key, and any additional keys.
Convert a PKCS 12 encrypted certificate package into a private key,
public key, and any additional keys.
Parameters
- $pkcs12
- $text The PKCS 12 data.
- $params
- The parameters needed for parsing.
<pre>Parameters:
===========
<span class="php-quote">'sslpath'</span> => The path to the OpenSSL binary. (REQUIRED)
<span class="php-quote">'password'</span> => The password to <span class="php-keyword1">use</span> to decrypt the data. (Optional)
<span class="php-quote">'newpassword'</span> => The password to <span class="php-keyword1">use</span> to encrypt the <span class="php-keyword1">private</span> <span class="php-keyword2">key</span>.
(Optional)</pre>
Returns
stdClass An object.
'private' - The private key in PEM format.
'public' - The public key in PEM format.
'certs' - An array of additional certs.
Throws
|