Allow the HealthVault web configuration to allow the cert store to be specified.

This commit is contained in:
Victor Vuong 2017-07-13 14:17:15 -07:00
Родитель e8238286ab
Коммит 3284afcf59
4 изменённых файлов: 16 добавлений и 1 удалений

Просмотреть файл

@ -11,6 +11,7 @@ using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Collections.Specialized; using System.Collections.Specialized;
using System.Linq; using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Web; using System.Web;
using System.Web.Configuration; using System.Web.Configuration;
using Microsoft.HealthVault.Configuration; using Microsoft.HealthVault.Configuration;
@ -75,6 +76,7 @@ namespace Microsoft.HealthVault.Web.Configuration
AllowedRedirectSites = appSettings[ConfigKeys.AllowedRedirectSites], AllowedRedirectSites = appSettings[ConfigKeys.AllowedRedirectSites],
ApplicationCertificateFileName = appSettings[ConfigKeys.ApplicationCertificateFileName], ApplicationCertificateFileName = appSettings[ConfigKeys.ApplicationCertificateFileName],
ApplicationCertificatePassword = appSettings[ConfigKeys.ApplicationCertificatePassword], ApplicationCertificatePassword = appSettings[ConfigKeys.ApplicationCertificatePassword],
CertStore = (StoreLocation)appSettings.GetTypedValue(ConfigKeys.CertStore, (int)ConfigDefaults.CertStore),
CertSubject = appSettings[ConfigKeys.CertSubject], CertSubject = appSettings[ConfigKeys.CertSubject],
CookieDomain = appSettings[ConfigKeys.CookieDomain] ?? ConfigDefaults.CookieDomain, CookieDomain = appSettings[ConfigKeys.CookieDomain] ?? ConfigDefaults.CookieDomain,
CookieEncryptionKey = GetEncryptionKey(appSettings[ConfigKeys.CookieEncryptionKey]), CookieEncryptionKey = GetEncryptionKey(appSettings[ConfigKeys.CookieEncryptionKey]),

Просмотреть файл

@ -8,6 +8,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Security.Cryptography.X509Certificates;
using System.Web;
using Microsoft.HealthVault.Configuration; using Microsoft.HealthVault.Configuration;
namespace Microsoft.HealthVault.Web.Configuration namespace Microsoft.HealthVault.Web.Configuration
@ -62,6 +64,14 @@ namespace Microsoft.HealthVault.Web.Configuration
/// </remarks> /// </remarks>
public string ApplicationCertificatePassword { get; internal set; } public string ApplicationCertificatePassword { get; internal set; }
/// <summary>
/// Gets the Certificate Store to use
/// </summary>
/// <remarks>
/// This property corresponds to the "HV_AppCertStore" configuration value when reading from web.config
/// </remarks>
public StoreLocation CertStore { get; internal set; }
/// <summary> /// <summary>
/// Gets the Certificate Subject. /// Gets the Certificate Subject.
/// </summary> /// </summary>

Просмотреть файл

@ -7,6 +7,7 @@
// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System; using System;
using System.Security.Cryptography.X509Certificates;
namespace Microsoft.HealthVault.Web.Constants namespace Microsoft.HealthVault.Web.Constants
{ {
@ -19,6 +20,7 @@ namespace Microsoft.HealthVault.Web.Constants
internal const string AppId = "HV_ApplicationId"; internal const string AppId = "HV_ApplicationId";
internal const string ApplicationCertificateFileName = "HV_ApplicationCertificateFilename"; internal const string ApplicationCertificateFileName = "HV_ApplicationCertificateFilename";
internal const string ApplicationCertificatePassword = "HV_ApplicationCertificatePassword"; internal const string ApplicationCertificatePassword = "HV_ApplicationCertificatePassword";
internal const string CertStore = "HV_AppCertStore";
internal const string CertSubject = "HV_AppCertSubject"; internal const string CertSubject = "HV_AppCertSubject";
internal const string CookieDomain = "HV_CookieDomain"; internal const string CookieDomain = "HV_CookieDomain";
internal const string CookieEncryptionKey = "HV_CookieEncryptionKey"; internal const string CookieEncryptionKey = "HV_CookieEncryptionKey";
@ -46,6 +48,7 @@ namespace Microsoft.HealthVault.Web.Constants
{ {
internal const string CookieNameSuffix = "_HV"; internal const string CookieNameSuffix = "_HV";
internal const bool IsMra = false; internal const bool IsMra = false;
internal const StoreLocation CertStore = StoreLocation.LocalMachine;
internal const string CookieDomain = ""; internal const string CookieDomain = "";
internal const string CookiePath = ""; internal const string CookiePath = "";
internal static readonly TimeSpan CookieTimeoutDuration = TimeSpan.FromMinutes(20); internal static readonly TimeSpan CookieTimeoutDuration = TimeSpan.FromMinutes(20);

Просмотреть файл

@ -34,7 +34,7 @@ namespace Microsoft.HealthVault.Web.Providers
_configuration = configuration; _configuration = configuration;
_applicationId = configuration.MasterApplicationId; _applicationId = configuration.MasterApplicationId;
_storeLocation = StoreLocation.LocalMachine; _storeLocation = configuration.CertStore;
_certSubject = "CN=" + GetApplicationCertificateSubject(); _certSubject = "CN=" + GetApplicationCertificateSubject();
_x509Certificate2 = GetApplicationCertificate(); _x509Certificate2 = GetApplicationCertificate();