private NuGetCertificate FindCert(CertificatesHub certs, StoreLocation storeLocation) { var specificMatch = certs.GetCertificateFromConfigSetting(ConfigSetting, StoreName.My, storeLocation); if (specificMatch != null) { AzureHubEventSource.Log.SingleMatch(storeLocation.ToString(), specificMatch.Thumbprint, specificMatch.Subject); return(specificMatch); } var candidates = certs .GetCertificatesByPurpose(CommonCertificatePurposes.AzureManagement, StoreName.My, storeLocation) .ToList(); // No candidates? Return null. if (candidates.Count == 0) { AzureHubEventSource.Log.NoMatch(storeLocation.ToString()); return(null); } // One candidate? Return it. else if (candidates.Count == 1) { AzureHubEventSource.Log.SingleMatch(storeLocation.ToString(), candidates[0].Thumbprint, candidates[0].Subject); return(candidates[0]); } // Multiple candidates? Return the first one else { var match = candidates.FirstOrDefault(); AzureHubEventSource.Log.MultipleMatches(storeLocation.ToString(), match.Thumbprint, match.Subject); return(match); } }
private NuGetCertificate FindCert(CertificatesHub certs, StoreLocation storeLocation) { var specificMatch = certs.GetCertificateFromConfigSetting(ConfigSetting, StoreName.My, storeLocation); if(specificMatch != null) { AzureHubEventSource.Log.SingleMatch(storeLocation.ToString(), specificMatch.Thumbprint, specificMatch.Subject); return specificMatch; } var candidates = certs .GetCertificatesByPurpose(CommonCertificatePurposes.AzureManagement, StoreName.My, storeLocation) .ToList(); // No candidates? Return null. if (candidates.Count == 0) { AzureHubEventSource.Log.NoMatch(storeLocation.ToString()); return null; } // One candidate? Return it. else if (candidates.Count == 1) { AzureHubEventSource.Log.SingleMatch(storeLocation.ToString(), candidates[0].Thumbprint, candidates[0].Subject); return candidates[0]; } // Multiple candidates? Return the first one else { var match = candidates.FirstOrDefault(); AzureHubEventSource.Log.MultipleMatches(storeLocation.ToString(), match.Thumbprint, match.Subject); return match; } }
public AzureHub(CertificatesHub certs) { ManagementCertificate = FindCert(certs); if (ManagementCertificate != null) { LoadSubscriptionIdentity(); } }
private NuGetCertificate FindCert(CertificatesHub certs) { return (FindCert(certs, StoreLocation.LocalMachine) ?? FindCert(certs, StoreLocation.CurrentUser)); }
private NuGetCertificate FindCert(CertificatesHub certs) { return FindCert(certs, StoreLocation.LocalMachine) ?? FindCert(certs, StoreLocation.CurrentUser); }