/// <summary> /// Retrieves the X509 Certificate used for the server side of TLS /// </summary> /// <param name="configuration">The gateway configuration</param> /// <returns>An X509 Certificate if available</returns> X509Certificate2 GetServerCertificate(GatewayConfiguration configuration) { X509Certificate2 certificate = null; switch (configuration.X509Location) { case GatewayConfiguration.CertificateLocation.Data: string certificateFile = Path.Combine(this.serviceContext.CodePackageActivationContext.GetDataPackageObject("Data").Path, configuration.X509Identifier); certificate = CertificateUtilities.GetCertificateFromFile(certificateFile, configuration.X509Credential); break; case GatewayConfiguration.CertificateLocation.KeyVault: // certificate = CertificateUtilities.GetCertificateFromKeyVault(certificateFile, this.configuration.X509Credential); throw new NotImplementedException(); case GatewayConfiguration.CertificateLocation.LocalStore: certificate = CertificateUtilities.GetCertificate(configuration.X509Identifier, StoreName.My, StoreLocation.LocalMachine); break; } return(certificate); }