When you are doing STS work (that goes beyond the hardcoded SDK samples), you need programmatic access to certificates from the store. To make this easier I hacked together a configuration section for certificate references, e.g.
<certificateReferences>
<add name=“Sts“
findValue=“CN=STS“
x509FindType=“FindBySubjectDistinguishedName“
storeLocation=“LocalMachine“
storeName=“My“ />
<add name=“http://localhost:9000/IssuedToken“
findValue=“CN=Service“
x509FindType=“FindBySubjectDistinguishedName“
storeLocation=“LocalMachine“
storeName=“AddressBook“ />
</certificateReferences>
…and a static class that gives you easy access to the certificate information (e.g. in your STS):
// get the encryption certificate for the requested service
private void SetTargetToken(string appliesTo)
{
CertificateReferenceElement config =
CertificateReference.GetReference(appliesTo);
ProofKeyEncryptionToken = FederationUtilities.GetX509TokenFromCert(
config.StoreName,
config.StoreLocation,
config.FindValue);
}
CertificateReference.zip (14.95 KB)