Last active
December 11, 2015 17:39
-
-
Save charlycoste/4636511 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| class OpenSSL_PKey | |
| { | |
| protected $pkey; | |
| public function __construct() | |
| { | |
| $this->pkey = openssl_pkey_new(); | |
| } | |
| public function __toString() | |
| { | |
| $key = ''; | |
| openssl_pkey_export($this->pkey, $key); | |
| return $key; | |
| } | |
| public function getDetails() | |
| { | |
| return openssl_pkey_get_details($this->pkey); | |
| } | |
| public function __destruct() | |
| { | |
| openssl_pkey_free($this->pkey); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| class OpenSSLCert | |
| { | |
| protected $options; | |
| protected $pkey; | |
| public function __construct(OpenSSLCertOptions $options, OpenSSLKey $key) | |
| { | |
| $this->options = $options; | |
| $this->pkey = $key; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| class OpenSSLCertOptions | |
| { | |
| protected $availableKeys = array( "countryName", | |
| "stateOrProvinceName", | |
| "localityName", | |
| "organizationName", | |
| "organizationalUnitName", | |
| "commonName", | |
| "emailAddress" ); | |
| protected $dn = array(); | |
| public function __call($name, $args) | |
| { | |
| if (in_array($name, $this->availableKeys)) { | |
| if (isset($args[0])) { | |
| $this->dn[$name] = $args[0]; | |
| return $this; | |
| } else { | |
| return $this->dn[$name]; | |
| } | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| class OpenSSLManager | |
| { | |
| public function createNewKey() | |
| { | |
| return new PKey(); | |
| } | |
| } |
Author
Author
openssl_sign prend une ressource de type "OpenSSL key" pour signer les données
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
openssl_pkey_get_privateetopenssl_pkey_get_publicretournent des ressources de type "OpenSSL key"openssl_pkey_exportpermet d'obtenir une clée sous forme d'une chaine de caractères