Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access public key string programmaticaly #305

Closed
scaytrase opened this issue Feb 14, 2017 · 3 comments
Closed

Access public key string programmaticaly #305

scaytrase opened this issue Feb 14, 2017 · 3 comments
Labels

Comments

@scaytrase
Copy link

In order to build extensible communications I want to publish my public key from signing key-pair as a separate controller file.

If I try to use the following code

    public function pubkeyAction()
    {
        $key = $this->get('lexik_jwt_authentication.key_loader')->loadKey('public');
        dump($key);

        return new Response(
            stream_get_contents($key),
            200,
            ['Content-Type' => 'text/plain']
        );
    }

it shows me

Warning: stream_get_contents(): supplied resource is not a valid stream resource

Is there any convenient way to export public key without knowing the nature of underlying library that reads the key from the filesystem?

I have an option to manually fetch the key from the container parameters, but I think this is not a good choice

@chalasr
Copy link
Collaborator

chalasr commented Feb 14, 2017

Sounds legit to me.
What do you think about adding an interface like e.g. KeyReaderInterface::readKey() and make the existing key loaders implement it?
Would you mind submit a PR?

@scaytrase
Copy link
Author

scaytrase commented Feb 14, 2017

Interface idea looks OK, maybe KeyDumper ? current Loader actually Reads keys already
not sure if I'm fully familiar with openssl and other libs to implement it properly

@chalasr
Copy link
Collaborator

chalasr commented Feb 14, 2017

No problem, I'll do.

maybe KeyDumper ?

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants