Example #1
0
 public AmqpConnection(Uri uri, AmqpCFXEndpoint endpoint, AuthenticationMode authMode)
 {
     SendTimout         = TimeSpan.FromSeconds(5);
     links              = new List <AmqpLink>();
     NetworkUri         = uri;
     Endpoint           = endpoint;
     AuthenticationMode = authMode;
 }
Example #2
0
 public AmqpConnection(Uri uri, AmqpCFXEndpoint endpoint, string virtualHostName = null, X509Certificate certificate = null)
 {
     SendTimout      = TimeSpan.FromSeconds(5);
     links           = new List <AmqpLink>();
     NetworkUri      = uri;
     Endpoint        = endpoint;
     Certificate     = certificate;
     VirtualHostName = virtualHostName;
 }
Example #3
0
 public AmqpConnection(Uri uri, AmqpCFXEndpoint endpoint, AuthenticationMode authMode, X509Certificate certificate = null, string targetHostName = null)
 {
     SendTimout         = TimeSpan.FromSeconds(5);
     links              = new List <AmqpLink>();
     NetworkUri         = uri;
     Endpoint           = endpoint;
     AuthenticationMode = authMode;
     Certificate        = certificate;
     TargetHostName     = targetHostName;
 }
Example #4
0
        public void Open(AmqpCFXEndpoint endpoint, X509Certificate2 certificate = null)
        {
            Endpoint = endpoint;

            IsOpen = false;
            if (string.IsNullOrEmpty(CFXHandle))
            {
                throw new ArgumentException("You must supply a CFX Handle");
            }

            inboundHost = new ContainerHost(RequestUri);

            if (!string.IsNullOrWhiteSpace(RequestUri.UserInfo))
            {
                inboundHost = new ContainerHost(new Uri[] { RequestUri }, null, RequestUri.UserInfo);
            }
            else
            {
                inboundHost = new ContainerHost(RequestUri);
            }

            var listener = inboundHost.Listeners[0];

            if (string.Compare(RequestUri.Scheme, "amqps", true) == 0)
            {
                listener.SSL.Certificate = certificate;
                listener.SSL.ClientCertificateRequired           = true;
                listener.SSL.RemoteCertificateValidationCallback = ValidateServerCertificate;
                listener.SASL.EnableExternalMechanism            = true;
            }

            if (string.IsNullOrWhiteSpace(RequestUri.UserInfo))
            {
                listener.SASL.EnableExternalMechanism  = false;
                listener.SASL.EnableAnonymousMechanism = true;
            }
            else
            {
                listener.SASL.EnableExternalMechanism  = true;
                listener.SASL.EnableAnonymousMechanism = false;
                //listener.SASL.EnablePlainMechanism(RequestUri.UserInfo.Split(':')[0], RequestUri.UserInfo.Split(':')[1]);
            }

            listener.SSL.Certificate = certificate;
            listener.SSL.ClientCertificateRequired           = true;
            listener.SSL.ClientCertificateRequired           = false;
            listener.SSL.RemoteCertificateValidationCallback = ValidateServerCertificate;

            inboundHost.Open();
            AppLog.Info($"Container host is listening on {RequestUri.Host}:{RequestUri.Port}.  User {RequestUri.UserInfo}");

            inboundHost.RegisterRequestProcessor(RequestHandle, new InternalRequestProcessor(this));
            AppLog.Info($"Request processor is registered on {RequestHandle}");
            IsOpen = true;
        }