Skip to content

Commit 88d5712

Browse files
committed
keys fix
1 parent 883d144 commit 88d5712

1 file changed

Lines changed: 24 additions & 6 deletions

File tree

src/DockerToken/Application.php

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,18 +197,25 @@ public function getLogger(){
197197
*/
198198
public function getKid()
199199
{
200-
return implode(':', array_slice(str_split(rtrim(Base32::encode(hash('sha256', $this->getPrivateKey(true), true)), '='), 4), 0, 12));
200+
return implode(':', array_slice(str_split(rtrim(Base32::encode(hash('sha256', $this->getPublicKey(true), true)), '='), 4), 0, 12));
201201
}
202202

203203
/**
204-
* open/decode the private key file
205-
*
206-
* @param bool|false $decode
204+
* open/decode the public key file
205+
*/
206+
protected function getPublicKey($decode = false)
207+
{
208+
return $this->openKey($this['options']['public_key'], $decode);
209+
}
210+
211+
/**
212+
* @param string $key
213+
* @param bool|false $decode
207214
* @return string
208215
*/
209-
protected function getPrivateKey($decode = false)
216+
protected function openKey($key, $decode = false)
210217
{
211-
$data = file_get_contents($this['options']['private_key']);
218+
$data = file_get_contents($key);
212219
if ($decode) {
213220
preg_match(self::PEM_PREG, $data, $m);
214221
return base64_decode(preg_replace('/\n|\r/', '', $m['DATA']));
@@ -217,4 +224,15 @@ protected function getPrivateKey($decode = false)
217224
}
218225
}
219226

227+
/**
228+
* open/decode the private key file
229+
*
230+
* @param bool|false $decode
231+
* @return string
232+
*/
233+
protected function getPrivateKey($decode = false)
234+
{
235+
return $this->openKey($this['options']['private_key'], $decode);
236+
}
237+
220238
}

0 commit comments

Comments
 (0)