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

Use preexisting cert? #29

Closed
eanders-MS opened this issue Mar 9, 2017 · 2 comments

Comments

Projects
None yet
2 participants
@eanders-MS
Copy link

commented Mar 9, 2017

Hello. I'd like to utilize this sample with an existing cert my local cert store. How can I export it to the format expected by the sample:

[
    {
        "customKeyIdentifier": "$base64Thumbprint_from_above",
        "keyId": "$keyid_from_above",
        "type": "AsymmetricX509Cert",
        "usage": "Verify",
        "value":  "$base64Value_from_above"
    }
]

I have the public and private key for the cert in question. How can I use what I have in my local certificate store to generate the above?

@jmprieur

This comment has been minimized.

Copy link
Contributor

commented Mar 9, 2017

@eanders-MS:
Note that I've just committed the changes to the Readme explaining how to automate the creation of the Azure AD applications, of the certificate, and updating the code to point to the Azure AD application (so the README.md now shows the automated way, whereas there is a new markdown file: https://github.com/Azure-Samples/active-directory-dotnet-daemon-certificate-credential/blob/master/Manual-Configuration-Steps.md apply which presents the manual steps.

That said to answer your question: if you know the thumbprint or subject of your certificate, you can get it with PowerShell.
Instead of running New-SelfSignedCertificate, you can use Get-ChildItem -Path Cert:\*path to the certificate*

For instance, assuming that the certificate is the current user's personal store, and the thumbprint is 0380BBAF358659AC0EF1BA472606CBD816BBC30E, you'll get the certificate by running in PowerShell
$cert = Get-ChildItem -Path Cert:\CurrentUser\My\0380BBAF358659AC0EF1BA472606CBD816BBC30E

then the rest of the instructions to compute the KeyCredential is the same.

@eanders-MS

This comment has been minimized.

Copy link
Author

commented Mar 9, 2017

Worked like a charm, and I learned something! Thanks.

@eanders-MS eanders-MS closed this Mar 9, 2017

jmprieur added a commit that referenced this issue Mar 10, 2017

Adding an FAQ section.
Adding a link to a question and its answer as this can be valuable for more people (issue #29)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.