Skip to content
This repository has been archived by the owner on Dec 17, 2019. It is now read-only.

Use preexisting cert? #29

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

Use preexisting cert? #29

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

Comments

@eanders-ms
Copy link

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
Copy link
Contributor

jmprieur 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
Copy link
Author

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

jmprieur added a commit that referenced this issue Mar 10, 2017
Adding a link to a question and its answer as this can be valuable for more people (issue #29)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants