|  | @@ -80,18 +80,26 @@ namespace Grpc.Core
 | 
	
		
			
				|  |  |      {
 | 
	
		
			
				|  |  |          readonly IList<KeyCertificatePair> keyCertificatePairs;
 | 
	
		
			
				|  |  |          readonly string rootCertificates;
 | 
	
		
			
				|  |  | +        readonly bool forceClientAuth;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          /// <summary>
 | 
	
		
			
				|  |  |          /// Creates server-side SSL credentials.
 | 
	
		
			
				|  |  |          /// </summary>
 | 
	
		
			
				|  |  | -        /// <param name="rootCertificates">PEM encoded client root certificates used to authenticate client.</param>
 | 
	
		
			
				|  |  |          /// <param name="keyCertificatePairs">Key-certificates to use.</param>
 | 
	
		
			
				|  |  | -        public SslServerCredentials(IEnumerable<KeyCertificatePair> keyCertificatePairs, string rootCertificates)
 | 
	
		
			
				|  |  | +        /// <param name="rootCertificates">PEM encoded client root certificates used to authenticate client.</param>
 | 
	
		
			
				|  |  | +        /// <param name="forceClientAuth">If true, client will be rejected unless it proves its unthenticity using against rootCertificates.</param>
 | 
	
		
			
				|  |  | +        public SslServerCredentials(IEnumerable<KeyCertificatePair> keyCertificatePairs, string rootCertificates, bool forceClientAuth)
 | 
	
		
			
				|  |  |          {
 | 
	
		
			
				|  |  |              this.keyCertificatePairs = new List<KeyCertificatePair>(keyCertificatePairs).AsReadOnly();
 | 
	
		
			
				|  |  |              Preconditions.CheckArgument(this.keyCertificatePairs.Count > 0,
 | 
	
		
			
				|  |  |                  "At least one KeyCertificatePair needs to be provided");
 | 
	
		
			
				|  |  | +            if (forceClientAuth)
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  | +                Preconditions.CheckNotNull(rootCertificates,
 | 
	
		
			
				|  |  | +                    "Cannot force client authentication unless you provide rootCertificates.");
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |              this.rootCertificates = rootCertificates;
 | 
	
		
			
				|  |  | +            this.forceClientAuth = forceClientAuth;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          /// <summary>
 | 
	
	
		
			
				|  | @@ -100,7 +108,7 @@ namespace Grpc.Core
 | 
	
		
			
				|  |  |          /// using client root certificates.
 | 
	
		
			
				|  |  |          /// </summary>
 | 
	
		
			
				|  |  |          /// <param name="keyCertificatePairs">Key-certificates to use.</param>
 | 
	
		
			
				|  |  | -        public SslServerCredentials(IEnumerable<KeyCertificatePair> keyCertificatePairs) : this(keyCertificatePairs, null)
 | 
	
		
			
				|  |  | +        public SslServerCredentials(IEnumerable<KeyCertificatePair> keyCertificatePairs) : this(keyCertificatePairs, null, false)
 | 
	
		
			
				|  |  |          {
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -126,6 +134,17 @@ namespace Grpc.Core
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +        /// <summary>
 | 
	
		
			
				|  |  | +        /// If true, the authenticity of client check will be enforced.
 | 
	
		
			
				|  |  | +        /// </summary>
 | 
	
		
			
				|  |  | +        public bool ForceClientAuthentication
 | 
	
		
			
				|  |  | +        {
 | 
	
		
			
				|  |  | +            get
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  | +                return this.forceClientAuth;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          internal override ServerCredentialsSafeHandle ToNativeCredentials()
 | 
	
		
			
				|  |  |          {
 | 
	
		
			
				|  |  |              int count = keyCertificatePairs.Count;
 | 
	
	
		
			
				|  | @@ -136,7 +155,7 @@ namespace Grpc.Core
 | 
	
		
			
				|  |  |                  certChains[i] = keyCertificatePairs[i].CertificateChain;
 | 
	
		
			
				|  |  |                  keys[i] = keyCertificatePairs[i].PrivateKey;
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -            return ServerCredentialsSafeHandle.CreateSslCredentials(rootCertificates, certChains, keys);
 | 
	
		
			
				|  |  | +            return ServerCredentialsSafeHandle.CreateSslCredentials(rootCertificates, certChains, keys, forceClientAuth);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  }
 |