C# SDK / GetBarSetAsync

Hey guys,
All of the sudden, I am seeing -

InnerException = {“The request was aborted: Could not create SSL/TLS secure channel.”}
Message = “An error occurred while sending the request.”

when trying to get Bars data - either Minute or Day. I tried renewing my API and Secret keys to no avail. Any insights are much appreciated.

Do you have a full error message?
Without any information, the URL might be incorrect, maybe accidentally hit a key while going through your code?

using:
Windows 7 SP1
.net Framework 4.8
Alpaca SDK 3.8.3

executing two commands:

  1. https://paper-api.alpaca.markets/v2/calendar?start=2020-10-19&end=2020-10-19

works as expected

  1. https://data.alpaca.markets/v1/last/stocks/AAPL

fails with {“The request was aborted: Could not create SSL/TLS secure channel.”}

Please let me know what else you need. Thanks.

PACKAGES -





















TRACE LOG - key bits are 90% of the way down - ‘Left with 0 client certificates to choose from’
System.Net.Http Verbose: 0 : [9624] Entering HttpClientHandler#34826618::.ctor()
System.Net.Http Verbose: 0 : [9624] Exiting HttpClientHandler#34826618::.ctor()
System.Net Information: 0 : [9624] Current OS installation type is ‘Client’.
System.Net.Http Verbose: 0 : [9624] Entering HttpClient#45004109::.ctor(HttpClientHandler#34826618)
System.Net.Http Information: 0 : [9624] Associating HttpClient#45004109 with HttpClientHandler#34826618
System.Net.Http Verbose: 0 : [9624] Exiting HttpClient#45004109::.ctor()
System.Net.Http Verbose: 0 : [9624] Entering HttpClient#45004109::.ctor(HttpClientHandler#34826618)
System.Net.Http Verbose: 0 : [9624] Exiting HttpClient#45004109::.ctor()
System.Net.Http Information: 0 : [9624] HttpClient#45004109 - BaseAddress: ‘’
System.Net.Http Verbose: 0 : [9624] Entering HttpClientHandler#2383799::.ctor()
System.Net.Http Verbose: 0 : [9624] Exiting HttpClientHandler#2383799::.ctor()
System.Net.Http Verbose: 0 : [9624] Entering HttpClient#21454193::.ctor(HttpClientHandler#2383799)
System.Net.Http Information: 0 : [9624] Associating HttpClient#21454193 with HttpClientHandler#2383799
System.Net.Http Verbose: 0 : [9624] Exiting HttpClient#21454193::.ctor()
System.Net.Http Verbose: 0 : [9624] Entering HttpClient#21454193::.ctor(HttpClientHandler#2383799)
System.Net.Http Verbose: 0 : [9624] Exiting HttpClient#21454193::.ctor()
System.Net.Http Information: 0 : [9624] HttpClient#21454193 - BaseAddress: ‘’
System.Net.Http Verbose: 0 : [9624] Entering FormUrlEncodedContent#58870012::.ctor()
System.Net.Http Verbose: 0 : [9624] Exiting FormUrlEncodedContent#58870012::.ctor()
System.Net.Http Verbose: 0 : [9624] Entering HttpRequestMessage#33675143::.ctor(Method: GET, Uri: ‘https://paper-api.alpaca.markets/v2/calendar?start=2020-10-19&end=2020-10-19’)
System.Net.Http Verbose: 0 : [9624] Exiting HttpRequestMessage#33675143::.ctor()
System.Net.Http Verbose: 0 : [9624] Entering HttpClient#45004109::SendAsync(HttpRequestMessage#33675143: Method: GET, RequestUri: ‘https://paper-api.alpaca.markets/v2/calendar?start=2020-10-19&end=2020-10-19’, Version: 1.1, Content: , Headers:
{
APCA-API-KEY-ID: PKK86HX0C3I7WQ2I9AR5
APCA-API-SECRET-KEY: P9L9aXOtcGjFfJ1SemJ8ua8tHJPGPaR5eQneX4yN
Accept: application/json
})
System.Net.Http Verbose: 0 : [9624] Entering HttpClientHandler#34826618::SendAsync(HttpRequestMessage#33675143)
System.Net Verbose: 0 : [9624] Entering HttpWebRequest#34640832::HttpWebRequest(https://paper-api.alpaca.markets/v2/calendar?start=2020-10-19&end=2020-10-19#2092813386)
System.Net Information: 0 : [9624] RAS supported: True
System.Net Verbose: 0 : [9624] Exiting HttpWebRequest#34640832::HttpWebRequest()
System.Net Verbose: 0 : [9624] Entering HttpWebRequest#34640832::HttpWebRequest(uri: ‘https://paper-api.alpaca.markets/v2/calendar?start=2020-10-19&end=2020-10-19’, connectionGroupName: ‘34826618’)
System.Net Verbose: 0 : [9624] Exiting HttpWebRequest#34640832::HttpWebRequest()
System.Net.Http Information: 0 : [9624] Associating HttpRequestMessage#33675143 with HttpWebRequest#34640832
System.Net.Http Verbose: 0 : [9624] Exiting HttpClientHandler#34826618::SendAsync() -> Task1#43332040 System.Net Verbose: 0 : [6120] Entering HttpWebRequest#34640832::BeginGetResponse() System.Net.Http Verbose: 0 : [9624] Exiting HttpClient#45004109::SendAsync() -> Task1#43332040
System.Net Verbose: 0 : [6120] Entering ServicePoint#4032828::ServicePoint(paper-api.alpaca.markets:443)
System.Net Information: 0 : [6120] Associating HttpWebRequest#34640832 with ServicePoint#4032828
System.Net Information: 0 : [6120] Associating Connection#33711845 with HttpWebRequest#34640832
System.Net Verbose: 0 : [6120] Exiting HttpWebRequest#34640832::BeginGetResponse() -> ContextAwareResult#37489757
System.Net Information: 0 : [4692] Connection#33711845 - Created connection from 192.168.0.100:52867 to 35.194.67.18:443.
System.Net Information: 0 : [4692] TlsStream#12547953::.ctor(host=paper-api.alpaca.markets, #certs=0, checkCertificateRevocationList=False, sslProtocols=Tls11, Tls12)
System.Net Information: 0 : [4692] Associating HttpWebRequest#34640832 with ConnectStream#11429296
System.Net Information: 0 : [4692] HttpWebRequest#34640832 - Request: GET /v2/calendar?start=2020-10-19&end=2020-10-19 HTTP/1.1

System.Net Information: 0 : [4692] ConnectStream#11429296 - Sending headers
{
APCA-API-KEY-ID: PKK86HX0C3I7WQ2I9AR5
APCA-API-SECRET-KEY: P9L9aXOtcGjFfJ1SemJ8ua8tHJPGPaR5eQneX4yN
Accept: application/json
Host: paper-api.alpaca.markets
Connection: Keep-Alive
}.
System.Net Information: 0 : [4692] SecureChannel#41622463::.ctor(hostname=paper-api.alpaca.markets, #clientCertificates=0, encryptionPolicy=RequireEncryption)
System.Net Information: 0 : [4692] Enumerating security packages:
System.Net Information: 0 : [4692] Negotiate
System.Net Information: 0 : [4692] NegoExtender
System.Net Information: 0 : [4692] Kerberos
System.Net Information: 0 : [4692] NTLM
System.Net Information: 0 : [4692] Schannel
System.Net Information: 0 : [4692] Microsoft Unified Security Protocol Provider
System.Net Information: 0 : [4692] WDigest
System.Net Information: 0 : [4692] TSSSP
System.Net Information: 0 : [4692] pku2u
System.Net Information: 0 : [4692] CREDSSP
System.Net Information: 0 : [4692] SecureChannel#41622463 - Left with 0 client certificates to choose from.
System.Net Information: 0 : [4692] SecureChannel#41622463::.AcquireClientCredentials, new SecureCredential() (flags=(ValidateManual, NoDefaultCred, SendAuxRecord, UseStrongCrypto), m_ProtocolFlags=(Tls11Client, Tls12Client), m_EncryptionPolicy=RequireEncryption)
System.Net Information: 0 : [4692] AcquireCredentialsHandle(package = Microsoft Unified Security Protocol Provider, intent = Outbound, scc = System.Net.SecureCredential)
System.Net Information: 0 : [4692] InitializeSecurityContext(credential = System.Net.SafeFreeCredential_SECURITY, context = (null), targetName = paper-api.alpaca.markets, inFlags = ReplayDetect, SequenceDetect, Confidentiality, AllocateMemory, InitManualCredValidation)
System.Net Information: 0 : [4692] InitializeSecurityContext(In-Buffer length=0, Out-Buffer length=184, returned code=ContinueNeeded).
System.Net Information: 0 : [5724] InitializeSecurityContext(credential = System.Net.SafeFreeCredential_SECURITY, context = d76290:1b3b4e0, targetName = paper-api.alpaca.markets, inFlags = ReplayDetect, SequenceDetect, Confidentiality, AllocateMemory, InitManualCredValidation)
System.Net Information: 0 : [5724] InitializeSecurityContext(In-Buffers count=2, Out-Buffer length=0, returned code=ContinueNeeded).
System.Net Information: 0 : [5724] InitializeSecurityContext(credential = System.Net.SafeFreeCredential_SECURITY, context = d76290:1b3b4e0, targetName = paper-api.alpaca.markets, inFlags = ReplayDetect, SequenceDetect, Confidentiality, AllocateMemory, InitManualCredValidation)
System.Net Information: 0 : [5724] InitializeSecurityContext(In-Buffers count=2, Out-Buffer length=0, returned code=ContinueNeeded).
System.Net Information: 0 : [5724] InitializeSecurityContext(credential = System.Net.SafeFreeCredential_SECURITY, context = d76290:1b3b4e0, targetName = paper-api.alpaca.markets, inFlags = ReplayDetect, SequenceDetect, Confidentiality, AllocateMemory, InitManualCredValidation)
System.Net Information: 0 : [5724] InitializeSecurityContext(In-Buffers count=2, Out-Buffer length=0, returned code=ContinueNeeded).
System.Net Information: 0 : [5724] InitializeSecurityContext(credential = System.Net.SafeFreeCredential_SECURITY, context = d76290:1b3b4e0, targetName = paper-api.alpaca.markets, inFlags = ReplayDetect, SequenceDetect, Confidentiality, AllocateMemory, InitManualCredValidation)
System.Net Information: 0 : [5724] InitializeSecurityContext(In-Buffers count=2, Out-Buffer length=150, returned code=ContinueNeeded).
System.Net Information: 0 : [6848] InitializeSecurityContext(credential = System.Net.SafeFreeCredential_SECURITY, context = d76290:1b3b4e0, targetName = paper-api.alpaca.markets, inFlags = ReplayDetect, SequenceDetect, Confidentiality, AllocateMemory, InitManualCredValidation)
System.Net Information: 0 : [6848] InitializeSecurityContext(In-Buffers count=2, Out-Buffer length=0, returned code=ContinueNeeded).
System.Net Information: 0 : [6848] InitializeSecurityContext(credential = System.Net.SafeFreeCredential_SECURITY, context = d76290:1b3b4e0, targetName = paper-api.alpaca.markets, inFlags = ReplayDetect, SequenceDetect, Confidentiality, AllocateMemory, InitManualCredValidation)
System.Net Information: 0 : [6848] InitializeSecurityContext(In-Buffers count=2, Out-Buffer length=0, returned code=OK).
System.Net Information: 0 : [6848] Remote certificate: [Version]
V3

[Subject]
CN=paper-api.alpaca.markets
Simple Name: paper-api.alpaca.markets
DNS Name: paper-api.alpaca.markets

[Issuer]
CN=Let’s Encrypt Authority X3, O=Let’s Encrypt, C=US
Simple Name: Let’s Encrypt Authority X3
DNS Name: Let’s Encrypt Authority X3

[Serial Number]
032344017306477AA8B909CBA98313282617

[Not Before]
8/24/2020 10:56:34 AM

[Not After]
11/22/2020 10:56:34 AM

[Thumbprint]
3BBAF62FFAF76880CF946535A959964B0E8DAB99

[Signature Algorithm]
sha256RSA(1.2.840.113549.1.1.11)

[Public Key]
Algorithm: RSA
Length: 2048
Key Blob: 30 82 01 0a 02 82 01 01 00 c2 85 49 71 34 85 bc 52 5a ff 1e 74 12 a6 fe 7c c3 1c 2f fe cf c8 25 3c 35 69 7e b7 41 a4 38 8a 17 56 69 9a f7 8e 95 00 89 9c 81 74 eb cb 24 80 7e 00 c1 87 ff 56 71 6b 1a 4e 9f 92 b1 cc a6 70 8f c9 22 8d 70 d8 ba 41 12 39 f4 c0 6f 42 49 f3 ad 4f c6 4d 51 7c 4d 58 1c 50 cb 8a 24 ff 30 5e e5 d0 ff 42 22 75 19 bc a8 74 69 aa 27 e2 21 6a 48 c2 da 7b 19 d6 b2 c2 2b 78 bd 79 f2 24 b…
System.Net Information: 0 : [6848] SecureChannel#41622463 - Remote certificate was verified as valid by the user.
System.Net Information: 0 : [6848] EndProcessAuthentication(Protocol=Tls12, Cipher=Aes128 128 bit strength, Hash=Sha1 160 bit strength, Key Exchange=44550 256 bit strength).
System.Net Information: 0 : [6848] Connection#33711845 - Received status line: Version=1.1, StatusCode=200, StatusDescription=OK.
System.Net Information: 0 : [6848] Connection#33711845 - Received headers
{
Connection: keep-alive
Access-Control-Allow-Credentials: true
Vary: Origin
Content-Length: 99
Content-Type: application/json; charset=UTF-8
Date: Tue, 20 Oct 2020 18:10:51 GMT
Server: nginx/1.16.1
}.
System.Net Information: 0 : [6848] ConnectStream#12036987::ConnectStream(Buffered 99 bytes.)
System.Net Information: 0 : [6848] Associating HttpWebRequest#34640832 with ConnectStream#12036987
System.Net Information: 0 : [6848] Associating HttpWebRequest#34640832 with HttpWebResponse#42715336
System.Net Verbose: 0 : [6848] Entering HttpWebRequest#34640832::EndGetResponse()
System.Net Verbose: 0 : [6848] Exiting HttpWebRequest#34640832::EndGetResponse() -> HttpWebResponse#42715336
System.Net.Http Verbose: 0 : [6848] Entering HttpResponseMessage#36963566::.ctor(StatusCode: 200, ReasonPhrase: ‘’)
System.Net.Http Verbose: 0 : [6848] Exiting HttpResponseMessage#36963566::.ctor()
System.Net.Http Information: 0 : [6848] Associating HttpResponseMessage#36963566 with HttpRequestMessage#33675143
System.Net Verbose: 0 : [6848] Entering HttpWebResponse#42715336::GetResponseStream()
System.Net Information: 0 : [6848] ContentLength=99
System.Net Verbose: 0 : [6848] Exiting HttpWebResponse#42715336::GetResponseStream() -> ConnectStream#12036987
System.Net.Http Verbose: 0 : [6848] Entering StreamContent#25474675::.ctor()
System.Net.Http Verbose: 0 : [6848] Exiting StreamContent#25474675::.ctor()
System.Net.Http Information: 0 : [6848] Associating StreamContent#25474675 with WebExceptionWrapperStream#3038911
System.Net.Http Information: 0 : [6848] Associating HttpResponseMessage#36963566 with StreamContent#25474675
System.Net.Http Information: 0 : [6848] HttpClient#45004109 - Request for HttpRequestMessage#33675143 completed successfully. Returning response HttpResponseMessage#36963566: StatusCode: 200, ReasonPhrase: ‘OK’, Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
Connection: keep-alive
Access-Control-Allow-Credentials: true
Vary: Origin
Date: Tue, 20 Oct 2020 18:10:51 GMT
Server: nginx/1.16.1
Content-Length: 99
Content-Type: application/json; charset=UTF-8
}
System.Net Verbose: 0 : [6848] Entering ConnectStream#12036987::Read()
System.Net Verbose: 0 : [6848] Data from ConnectStream#12036987::Read
System.Net Verbose: 0 : [6848] 00000000 : 5B 7B 22 64 61 74 65 22-3A 22 32 30 32 30 2D 31 : [{“date”:“2020-1
System.Net Verbose: 0 : [6848] 00000010 : 30 2D 31 39 22 2C 22 6F-70 65 6E 22 3A 22 30 39 : 0-19”,“open”:“09
System.Net Verbose: 0 : [6848] 00000020 : 3A 33 30 22 2C 22 63 6C-6F 73 65 22 3A 22 31 36 : :30”,“close”:“16
System.Net Verbose: 0 : [6848] 00000030 : 3A 30 30 22 2C 22 73 65-73 73 69 6F 6E 5F 6F 70 : :00”,“session_op
System.Net Verbose: 0 : [6848] 00000040 : 65 6E 22 3A 22 30 37 30-30 22 2C 22 73 65 73 73 : en”:“0700”,“sess
System.Net Verbose: 0 : [6848] 00000050 : 69 6F 6E 5F 63 6C 6F 73-65 22 3A 22 31 39 30 30 : ion_close”:"1900
System.Net Verbose: 0 : [6848] 00000060 : 22 7D 5D : "}]
System.Net Verbose: 0 : [6848] Exiting ConnectStream#12036987::Read() -> Int32#99
System.Net Verbose: 0 : [6848] Entering ConnectStream#12036987::Close()
System.Net Verbose: 0 : [6848] Exiting ConnectStream#12036987::Close()
System.Net Verbose: 0 : [6848] Entering ConnectStream#12036987::Close()
System.Net Verbose: 0 : [6848] Exiting ConnectStream#12036987::Close()
System.Net Verbose: 0 : [6848] Entering ConnectStream#12036987::Close()
System.Net Verbose: 0 : [6848] Exiting ConnectStream#12036987::Close()
System.Net Verbose: 0 : [6848] Entering ConnectStream#12036987::Close()
System.Net Verbose: 0 : [6848] Exiting ConnectStream#12036987::Close()
System.Net.Http Verbose: 0 : [6848] Entering HttpRequestMessage#60082571::.ctor(Method: GET, Uri: ‘v1/last/stocks/AAPL’)
System.Net.Http Verbose: 0 : [6848] Exiting HttpRequestMessage#60082571::.ctor()
System.Net.Http Verbose: 0 : [6120] Entering HttpClient#21454193::SendAsync(HttpRequestMessage#60082571: Method: GET, RequestUri: ‘https://data.alpaca.markets/v1/last/stocks/AAPL’, Version: 1.1, Content: , Headers:
{
APCA-API-KEY-ID: PKK86HX0C3I7WQ2I9AR5
APCA-API-SECRET-KEY: P9L9aXOtcGjFfJ1SemJ8ua8tHJPGPaR5eQneX4yN
Accept: application/json
})
System.Net.Http Verbose: 0 : [6120] Entering HttpClientHandler#2383799::SendAsync(HttpRequestMessage#60082571)
System.Net Verbose: 0 : [6120] Entering HttpWebRequest#64828693::HttpWebRequest(https://data.alpaca.markets/v1/last/stocks/AAPL#1216711469)
System.Net Verbose: 0 : [6120] Exiting HttpWebRequest#64828693::HttpWebRequest()
System.Net Verbose: 0 : [6120] Entering HttpWebRequest#64828693::HttpWebRequest(uri: ‘https://data.alpaca.markets/v1/last/stocks/AAPL’, connectionGroupName: ‘2383799’)
System.Net Verbose: 0 : [6120] Exiting HttpWebRequest#64828693::HttpWebRequest()
System.Net.Http Information: 0 : [6120] Associating HttpRequestMessage#60082571 with HttpWebRequest#64828693
System.Net.Http Verbose: 0 : [6120] Exiting HttpClientHandler#2383799::SendAsync() -> Task1#10104599 System.Net.Http Verbose: 0 : [6120] Exiting HttpClient#21454193::SendAsync() -> Task1#10104599
System.Net Verbose: 0 : [6556] Entering HttpWebRequest#64828693::BeginGetResponse()
System.Net Verbose: 0 : [6556] Entering ServicePoint#6044116::ServicePoint(data.alpaca.markets:443)
System.Net Information: 0 : [6556] Associating HttpWebRequest#64828693 with ServicePoint#6044116
System.Net Information: 0 : [6556] Associating Connection#59817589 with HttpWebRequest#64828693
System.Net Verbose: 0 : [6556] Exiting HttpWebRequest#64828693::BeginGetResponse() -> ContextAwareResult#48209832
System.Net Information: 0 : [4692] Connection#59817589 - Created connection from 192.168.0.100:52869 to 34.86.145.125:443.
System.Net Information: 0 : [4692] TlsStream#31364015::.ctor(host=data.alpaca.markets, #certs=0, checkCertificateRevocationList=False, sslProtocols=Tls11, Tls12)
System.Net Information: 0 : [4692] Associating HttpWebRequest#64828693 with ConnectStream#28379535
System.Net Information: 0 : [4692] HttpWebRequest#64828693 - Request: GET /v1/last/stocks/AAPL HTTP/1.1

System.Net Information: 0 : [4692] ConnectStream#28379535 - Sending headers
{
APCA-API-KEY-ID: PKK86HX0C3I7WQ2I9AR5
APCA-API-SECRET-KEY: P9L9aXOtcGjFfJ1SemJ8ua8tHJPGPaR5eQneX4yN
Accept: application/json
Host: data.alpaca.markets
Connection: Keep-Alive
}.
System.Net Information: 0 : [4692] SecureChannel#64109423::.ctor(hostname=data.alpaca.markets, #clientCertificates=0, encryptionPolicy=RequireEncryption)
System.Net Information: 0 : [4692] SecureChannel#64109423 - Left with 0 client certificates to choose from.
System.Net Information: 0 : [4692] Using the cached credential handle.
System.Net Information: 0 : [4692] InitializeSecurityContext(credential = System.Net.SafeFreeCredential_SECURITY, context = (null), targetName = data.alpaca.markets, inFlags = ReplayDetect, SequenceDetect, Confidentiality, AllocateMemory, InitManualCredValidation)
System.Net Information: 0 : [4692] InitializeSecurityContext(In-Buffer length=0, Out-Buffer length=179, returned code=ContinueNeeded).
System.Net Information: 0 : [4692] InitializeSecurityContext(credential = System.Net.SafeFreeCredential_SECURITY, context = d76290:1b09420, targetName = data.alpaca.markets, inFlags = ReplayDetect, SequenceDetect, Confidentiality, AllocateMemory, InitManualCredValidation)
System.Net Information: 0 : [4692] InitializeSecurityContext(In-Buffers count=2, Out-Buffer length=0, returned code=IllegalMessage).
System.Net Error: 0 : [4692] Exception in HttpWebRequest#64828693:: - The request was aborted: Could not create SSL/TLS secure channel…
System.Net Verbose: 0 : [4692] Entering HttpWebRequest#64828693::EndGetResponse()
System.Net Error: 0 : [4692] Exception in HttpWebRequest#64828693::EndGetResponse - The request was aborted: Could not create SSL/TLS secure channel…
System.Net.Http Error: 0 : [4692] Exception in HttpClientHandler#2383799::SendAsync - The request was aborted: Could not create SSL/TLS secure channel…
at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar)
System.Net.Http Error: 0 : [4692] HttpClient#21454193::SendAsync() - An error occurred while sending HttpRequestMessage#60082571. System.Net.Http.HttpRequestException: An error occurred while sending the request. —> System.Net.WebException: The request was aborted: Could not create SSL/TLS secure channel.
at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar)
— End of inner exception stack trace —