public static BindingInfo FromMap(IReadOnlyDictionary <string, RuntimeValue> map) { if (map == null) { return(null); } string ipAddress = map.GetValueOrDefault("IPAddress").AsString(); string port = map.GetValueOrDefault("Port").AsString(); if (string.IsNullOrEmpty(ipAddress) || string.IsNullOrEmpty(port)) { return(null); } string hostName = map.GetValueOrDefault("HostName").AsString(); string certificateStoreName = map.GetValueOrDefault("CertificateStoreName").AsString(); string protocol = map.GetValueOrDefault("Protocol").AsString(); string certificateHash = map.GetValueOrDefault("CertificateHash").AsString(); BindingSslFlags sslFlags = 0; if (map.GetValueOrDefault("ServerNameIndication").AsBoolean() ?? false) { sslFlags |= BindingSslFlags.ServerNameIndication; } if (map.GetValueOrDefault("UseCentralizedStore").AsBoolean() ?? false) { sslFlags |= BindingSslFlags.UseCentralizedStore; } return(new BindingInfo(ipAddress, port, hostName, protocol, certificateStoreName, HexStringToByteArray(certificateHash), sslFlags)); }
public BindingInfo(string ipAddress, string port, string hostName, string protocol, string certificateStoreName, byte[] certificateHash, BindingSslFlags sslFlags) { if (string.IsNullOrEmpty(ipAddress)) { throw new ArgumentNullException(nameof(ipAddress)); } if (string.IsNullOrEmpty(port)) { throw new ArgumentNullException(nameof(port)); } this.IpAddress = AH.CoalesceString(ipAddress.Trim(), "*"); this.Port = port.Trim(); this.HostName = hostName?.Trim() ?? string.Empty; this.Protocol = AH.CoalesceString(protocol?.Trim(), "http"); this.CertificateStoreName = AH.CoalesceString(certificateStoreName?.Trim(), "My"); this.CertificateHash = certificateHash ?? new byte[0]; this.SslFlags = sslFlags; }