Amazon ec2 连接到AWS上的Windows Server服务总线

Amazon ec2 连接到AWS上的Windows Server服务总线,amazon-ec2,amazon-web-services,servicebus,azureservicebus,Amazon Ec2,Amazon Web Services,Servicebus,Azureservicebus,我正在使用新的Windows Server Service Bus 1.0测试版开始一个新项目的工作。我正在尝试在AWS EC2虚拟机上设置测试环境 我已经在AWS EC2上运行的Windows Server 2008 R2实例上安装了服务总线,并根据MSDN文档中的示例设置了新的服务器场、容器和主机。我在服务器上打开了所有正确的端口(4443和9354)。我还按照[本页][1]中的说明将自行生成的证书导出到我的客户机上 我有一个非常简单的C#程序,它创建一个队列,对一条消息进行排队,然后接收它

我正在使用新的Windows Server Service Bus 1.0测试版开始一个新项目的工作。我正在尝试在AWS EC2虚拟机上设置测试环境

我已经在AWS EC2上运行的Windows Server 2008 R2实例上安装了服务总线,并根据MSDN文档中的示例设置了新的服务器场、容器和主机。我在服务器上打开了所有正确的端口(4443和9354)。我还按照[本页][1]中的说明将自行生成的证书导出到我的客户机上

我有一个非常简单的C#程序,它创建一个队列,对一条消息进行排队,然后接收它。当我将可执行文件复制到VM并在那里运行它时,这个程序运行良好,因此我相信我正确地使用了API。但是,当我从指向AWS服务器的本地开发框运行程序时,会出现安全异常

我的代码如下所示:

var servername=“X.X.X.X”;//System.Net.WebException:基础连接已关闭:无法为SSL/TLS安全通道建立信任关系。-->System.Security.Authentication.AuthenticationException:根据验证过程,远程证书无效。
位于System.Net.Security.SslState.StartSendAuthResetSignal(ProtocolToken消息、AsyncProtocolRequest asyncRequest、异常)
位于System.Net.Security.SslState.StartSendBlob(字节[]传入,Int32计数,AsyncProtocolRequest asyncRequest)
位于System.Net.Security.SslState.ProcessReceivedBlob(字节[]缓冲区,Int32计数,AsyncProtocolRequest asyncRequest)
位于System.Net.Security.SslState.StartReceiveBlob(字节[]缓冲区,AsyncProtocolRequest asyncRequest)
位于System.Net.Security.SslState.StartSendBlob(字节[]传入,Int32计数,AsyncProtocolRequest asyncRequest)
位于System.Net.Security.SslState.ProcessReceivedBlob(字节[]缓冲区,Int32计数,AsyncProtocolRequest asyncRequest)
位于System.Net.Security.SslState.StartReceiveBlob(字节[]缓冲区,AsyncProtocolRequest asyncRequest)
位于System.Net.Security.SslState.StartSendBlob(字节[]传入,Int32计数,AsyncProtocolRequest asyncRequest)
位于System.Net.Security.SslState.ProcessReceivedBlob(字节[]缓冲区,Int32计数,AsyncProtocolRequest asyncRequest)
位于System.Net.Security.SslState.StartReceiveBlob(字节[]缓冲区,AsyncProtocolRequest asyncRequest)
位于System.Net.Security.SslState.StartSendBlob(字节[]传入,Int32计数,AsyncProtocolRequest asyncRequest)
位于System.Net.Security.SslState.ForceAuthentication(布尔值receiveFirst,字节[]缓冲区,AsyncProtocolRequest asyncRequest)
在System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult-lazyResult)上
位于System.Threading.ExecutionContext.RunInternal(ExecutionContext ExecutionContext、ContextCallback回调、对象状态、布尔值preserveSyncCtx)
在System.Threading.ExecutionContext.Run(ExecutionContext ExecutionContext,ContextCallback回调,对象状态,布尔保存SyncCTX)
在System.Threading.ExecutionContext.Run(ExecutionContext ExecutionContext,ContextCallback回调,对象状态)
在System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult)上
在System.Net.TlsStream.Write(字节[]缓冲区,Int32偏移量,Int32大小)
在System.Net.PooledStream.Write(字节[]缓冲区,Int32偏移量,Int32大小)
位于System.Net.ConnectStream.WriteHeaders(布尔异步)
---内部异常堆栈跟踪的结束---
位于System.Net.HttpWebRequest.GetRequestStream(TransportContext和context)
在System.Net.HttpWebRequest.GetRequestStream()中
位于Microsoft.ServiceBus.TokenProviderHelper.GetWindowsAccessTokenCore(IEnumerator`1 stsUris,Func`2 uriBuilder,String requestToken,TimeSpan timeout,DateTime&expiresIn)
---内部异常堆栈跟踪的结束---
位于Microsoft.ServiceBus.TokenProviderHelper.ThroweException(Uri requestUri,WebException)
位于Microsoft.ServiceBus.TokenProviderHelper.GetWindowsAccessTokenCore(IEnumerator`1 stsUris,Func`2 uriBuilder,String requestToken,TimeSpan timeout,DateTime&expiresIn)
位于Microsoft.ServiceBus.WindowsTokenProvider.OnBeginGetWebToken(字符串appliesTo、字符串操作、时间跨度超时、异步回调、对象状态)
位于Microsoft.ServiceBus.TokenProvider.GetWebTokenAsyncResult..ctor(TokenProvider TokenProvider、字符串appliesTo、字符串操作、布尔旁路缓存、TimeSpan超时、异步回调、对象状态)
位于Microsoft.ServiceBus.TokenProvider.BeginGetWebToken(字符串appliesTo、字符串操作、布尔旁路缓存、TimeSpan超时、异步回调、对象状态)
位于Microsoft.ServiceBus.TokenProviderUtility.GetMessagingWebToken(ITokenProvider tokenProvider、字符串appliesTo、字符串操作、布尔旁路缓存、TimeSpan超时)
---内部异常堆栈跟踪的结束---
位于Microsoft.ServiceBus.TokenProviderUtility.GetMessagingWebToken(ITokenProvider tokenProvider、字符串appliesTo、字符串操作、布尔旁路缓存、TimeSpan超时)
位于Microsoft.ServiceBus.Messaging.HttpWebRequestExtensions.AddAuthorizationHeader(HttpWebRequest请求、ITokenProvider令牌提供程序、Uri基地址、字符串操作)
在Microsoft.ServiceBus.Messaging.ServiceBusResourceOperations.GetAsyncResult`1.d_uc.MoveNext()中
在Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.MoveNextStep()中
Microsoft.ServiceBus.dll中发生类型为“System.UnauthorizedAccessException”的第一次意外异常
System.UnauthorizedAccessException:令牌提供程序在访问时无法提供安全令牌'https://107.23.15.5:4446/APIHealthcare/$STS/Windows/”。令牌提供程序返回消息:“基础连接已关闭:无法为SSL/TLS安全通道建立信任关系”。-->System.IdentityModel.Tokens.SecurityTokenException:令牌提供程序在访问“”时无法提供安全令牌https://107.23.15.5:4446/APIHealthcare/$STS/Windows/”。令牌提供者
var servername = "X.X.X.X"; // <-- An IP Address, not FQDN
var sbNamespace = "MyNamespace";
var httpPort = 4446;
var tcpPort = 9354;

//create SB uris
var rootAddressManagement = ServiceBusEnvironment.CreatePathBasedServiceUri("sb", sbNamespace, string.Format("{0}:{1}", servername, httpPort));
var rootAddressRuntime = ServiceBusEnvironment.CreatePathBasedServiceUri("sb", sbNamespace, string.Format("{0}:{1}", servername, tcpPort));

var tokenProvider = TokenProvider.CreateWindowsTokenProvider(new List<Uri>() { rootAddressManagement });
var namespaceManager = new NamespaceManager(rootAddressManagement, 
    new NamespaceManagerSettings()
    {
        TokenProvider = tokenProvider
    });
var factory = MessagingFactory.Create(rootAddressRuntime,
    new MessagingFactorySettings()
    {
        TokenProvider = tokenProvider,
        //OperationTimeout = TimeSpan.FromMinutes(30)
    });

if (!namespaceManager.QueueExists("OrderQueue")) <-- EXCEPTION OCCURRS HERE
{
    // Code to create a queue that is never reached.
}
[Microsoft.ServiceBus.Messaging.ServiceBusResourceOperations+GetAsyncResult`1[[Microsoft.ServiceBus.Messaging.QueueDescription, Microsoft.ServiceBus, Version=1.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]] IteratorAsyncResult failed to move to the next step due to an exception; System.UnauthorizedAccessException: The token provider was unable to provide a security token while accessing 'https://107.23.15.5:4446/APIHealthcare/$STS/Windows/'. Token provider returned message: 'The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.'. ---> System.IdentityModel.Tokens.SecurityTokenException: The token provider was unable to provide a security token while accessing 'https://107.23.15.5:4446/APIHealthcare/$STS/Windows/'. Token provider returned message: 'The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.'. ---> System.Net.WebException: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel. ---> System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure.
   at System.Net.Security.SslState.StartSendAuthResetSignal(ProtocolToken message, AsyncProtocolRequest asyncRequest, Exception exception)
   at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result)
   at System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size)
   at System.Net.PooledStream.Write(Byte[] buffer, Int32 offset, Int32 size)
   at System.Net.ConnectStream.WriteHeaders(Boolean async)
   --- End of inner exception stack trace ---
   at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
   at System.Net.HttpWebRequest.GetRequestStream()
   at Microsoft.ServiceBus.TokenProviderHelper.GetWindowsAccessTokenCore(IEnumerator`1 stsUris, Func`2 uriBuilder, String requestToken, TimeSpan timeout, DateTime& expiresIn)
   --- End of inner exception stack trace ---
   at Microsoft.ServiceBus.TokenProviderHelper.ThrowException(Uri requestUri, WebException exception)
   at Microsoft.ServiceBus.TokenProviderHelper.GetWindowsAccessTokenCore(IEnumerator`1 stsUris, Func`2 uriBuilder, String requestToken, TimeSpan timeout, DateTime& expiresIn)
   at Microsoft.ServiceBus.WindowsTokenProvider.OnBeginGetWebToken(String appliesTo, String action, TimeSpan timeout, AsyncCallback callback, Object state)
   at Microsoft.ServiceBus.TokenProvider.GetWebTokenAsyncResult..ctor(TokenProvider tokenProvider, String appliesTo, String action, Boolean bypassCache, TimeSpan timeout, AsyncCallback callback, Object state)
   at Microsoft.ServiceBus.TokenProvider.BeginGetWebToken(String appliesTo, String action, Boolean bypassCache, TimeSpan timeout, AsyncCallback callback, Object state)
   at Microsoft.ServiceBus.TokenProviderUtility.GetMessagingWebToken(ITokenProvider tokenProvider, String appliesTo, String action, Boolean bypassCache, TimeSpan timeout)
   --- End of inner exception stack trace ---
   at Microsoft.ServiceBus.TokenProviderUtility.GetMessagingWebToken(ITokenProvider tokenProvider, String appliesTo, String action, Boolean bypassCache, TimeSpan timeout)
   at Microsoft.ServiceBus.Messaging.HttpWebRequestExtensions.AddAuthorizationHeader(HttpWebRequest request, ITokenProvider tokenProvider, Uri baseAddress, String action)
   at Microsoft.ServiceBus.Messaging.ServiceBusResourceOperations.GetAsyncResult`1.<GetAsyncSteps>d__c.MoveNext()
   at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.MoveNextStep()
A first chance exception of type 'System.UnauthorizedAccessException' occurred in Microsoft.ServiceBus.dll
System.UnauthorizedAccessException: The token provider was unable to provide a security token while accessing 'https://107.23.15.5:4446/APIHealthcare/$STS/Windows/'. Token provider returned message: 'The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.'. ---> System.IdentityModel.Tokens.SecurityTokenException: The token provider was unable to provide a security token while accessing 'https://107.23.15.5:4446/APIHealthcare/$STS/Windows/'. Token provider returned message: 'The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.'. ---> System.Net.WebException: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel. ---> System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure.
   at System.Net.Security.SslState.StartSendAuthResetSignal(ProtocolToken message, AsyncProtocolRequest asyncRequest, Exception exception)
   at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result)
   at System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size)
   at System.Net.PooledStream.Write(Byte[] buffer, Int32 offset, Int32 size)
   at System.Net.ConnectStream.WriteHeaders(Boolean async)
   --- End of inner exception stack trace ---
   at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
   at System.Net.HttpWebRequest.GetRequestStream()
   at Microsoft.ServiceBus.TokenProviderHelper.GetWindowsAccessTokenCore(IEnumerator`1 stsUris, Func`2 uriBuilder, String requestToken, TimeSpan timeout, DateTime& expiresIn)
   --- End of inner exception stack trace ---
   at Microsoft.ServiceBus.TokenProviderHelper.ThrowException(Uri requestUri, WebException exception)
   at Microsoft.ServiceBus.TokenProviderHelper.GetWindowsAccessTokenCore(IEnumerator`1 stsUris, Func`2 uriBuilder, String requestToken, TimeSpan timeout, DateTime& expiresIn)
   at Microsoft.ServiceBus.WindowsTokenProvider.OnBeginGetWebToken(String appliesTo, String action, TimeSpan timeout, AsyncCallback callback, Object state)
   at Microsoft.ServiceBus.TokenProvider.GetWebTokenAsyncResult..ctor(TokenProvider tokenProvider, String appliesTo, String action, Boolean bypassCache, TimeSpan timeout, AsyncCallback callback, Object state)
   at Microsoft.ServiceBus.TokenProvider.BeginGetWebToken(String appliesTo, String action, Boolean bypassCache, TimeSpan timeout, AsyncCallback callback, Object state)
   at Microsoft.ServiceBus.TokenProviderUtility.GetMessagingWebToken(ITokenProvider tokenProvider, String appliesTo, String action, Boolean bypassCache, TimeSpan timeout)
   --- End of inner exception stack trace ---

Server stack trace: 
   at Microsoft.ServiceBus.TokenProviderUtility.GetMessagingWebToken(ITokenProvider tokenProvider, String appliesTo, String action, Boolean bypassCache, TimeSpan timeout)
   at Microsoft.ServiceBus.Messaging.HttpWebRequestExtensions.AddAuthorizationHeader(HttpWebRequest request, ITokenProvider tokenProvider, Uri baseAddress, String action)
   at Microsoft.ServiceBus.Messaging.ServiceBusResourceOperations.GetAsyncResult`1.<GetAsyncSteps>d__c.MoveNext()
   at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.MoveNextStep()
   at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.EnumerateSteps(CurrentThreadType state)
   at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.Start()

Exception rethrown at [0]: 
   at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
   at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.End(IAsyncResult asyncResult)
   at Microsoft.ServiceBus.Messaging.ServiceBusResourceOperations.EndGet[TEntityDescription](IAsyncResult asyncResult)
   at Microsoft.ServiceBus.NamespaceManager.OnEndQueueExists(IAsyncResult result)
   at Microsoft.ServiceBus.NamespaceManager.EndQueueExists(IAsyncResult result)
   at Microsoft.ServiceBus.NamespaceManager.QueueExists(String path)
   at ServiceBusSandbox.ServiceBusSampleApp.CreateAQueue(NamespaceManager namespaceManager) in c:\Users\cent049\Documents\Visual Studio 2012\Projects\ServiceBusSandbox\ServiceBusSandbox\ServiceBusSampleApp.cs:line 15
   at ServiceBusSandbox.ServiceBusSampleApp.Main(String[] args) in c:\Users\cent049\DocumentThe thread 'vshost.RunParkingWindow' (0x2608) has exited with code 0 (0x0).