1 | <?php |
||
22 | class Certificate implements SignatureInterface, VerificationInterface |
||
23 | { |
||
24 | /** |
||
25 | * @var \NFePHP\Common\Certificate\PrivateKey |
||
26 | */ |
||
27 | public $privateKey; |
||
28 | |||
29 | /** |
||
30 | * @var \NFePHP\Common\Certificate\PublicKey |
||
31 | */ |
||
32 | public $publicKey; |
||
33 | |||
34 | /** |
||
35 | * @var \NFePHP\Common\Certificate\CertificationChain |
||
36 | */ |
||
37 | public $chainKeys; |
||
38 | |||
39 | /** |
||
40 | * Constructor |
||
41 | * @param \NFePHP\Common\Certificate\PrivateKey $privateKey |
||
42 | * @param \NFePHP\Common\Certificate\PublicKey $publicKey |
||
43 | * @param \NFePHP\Common\Certificate\CertificationChain $chainKeys |
||
44 | */ |
||
45 | 7 | public function __construct(PrivateKey $privateKey, PublicKey $publicKey, CertificationChain $chainKeys) |
|
51 | |||
52 | /** |
||
53 | * Read PFX and return this class |
||
54 | * @param string $content |
||
55 | * @param string $password |
||
56 | * @return \NFePHP\Common\Certificate |
||
57 | * @throws CertificateException |
||
58 | */ |
||
59 | 6 | public static function readPfx($content, $password) |
|
77 | |||
78 | /** |
||
79 | * Returns a PFX string with certification chain if exists |
||
80 | * @param string $password |
||
81 | * @return string |
||
82 | */ |
||
83 | public function writePfx($password) |
||
101 | |||
102 | /** |
||
103 | * Gets company name. |
||
104 | * @return string |
||
105 | */ |
||
106 | 2 | public function getCompanyName() |
|
110 | |||
111 | /** |
||
112 | * Gets start date. |
||
113 | * @return \DateTime Returns start date. |
||
114 | */ |
||
115 | 3 | public function getValidFrom() |
|
119 | |||
120 | /** |
||
121 | * Gets end date. |
||
122 | * @return \DateTime Returns end date. |
||
123 | */ |
||
124 | 2 | public function getValidTo() |
|
128 | |||
129 | /** |
||
130 | * Check if certificate has been expired. |
||
131 | * @return bool Returns true when it is truth, otherwise false. |
||
132 | */ |
||
133 | 3 | public function isExpired() |
|
137 | |||
138 | /** |
||
139 | * Gets CNPJ by OID '2.16.76.1.3.3' from ASN.1 certificate struture |
||
140 | * @return string |
||
141 | */ |
||
142 | public function getCnpj() |
||
146 | |||
147 | /** |
||
148 | * Gets CPF by OID '2.16.76.1.3.1' from ASN.1 certificate struture |
||
149 | * @return string |
||
150 | */ |
||
151 | public function getCpf() |
||
155 | |||
156 | /** |
||
157 | * {@inheritdoc} |
||
158 | */ |
||
159 | 3 | public function sign($content, $algorithm = OPENSSL_ALGO_SHA1) |
|
163 | |||
164 | /** |
||
165 | * {@inheritdoc} |
||
166 | */ |
||
167 | 2 | public function verify($data, $signature, $algorithm = OPENSSL_ALGO_SHA1) |
|
171 | |||
172 | /** |
||
173 | * Returns public key and chain in PEM format |
||
174 | * @return string |
||
175 | */ |
||
176 | 1 | public function __toString() |
|
184 | } |
||
185 |