I've been trying to pass a custom cert within a class function and I'm clearly doing something wrong because it fails on handshake. Please see the code below.
Public Shared Async Function RevealViaForwardProxy(ByVal redactData As String) As Task(Of String)
Dim proxy = New WebProxy($"http://{forwardProxy}")
Dim cert As X509Certificate = X509Certificate.CreateFromCertFile("c:/Users/User/vb/cert.pem")
Dim credentials = New NetworkCredential(username, password)
proxy.Credentials = credentials
Dim client = New HttpClientHandler()
client.Proxy = proxy
client.BaseAddress = New Uri("https://httpbin.org/")
Dim response = Await client.PostAsync("/post", New StringContent(redactData))
Dim responseBody = Await response.Content.ReadAsStringAsync
Return JObject.Parse(responseBody)("data").ToObject(Of String)
End Function
For example in Python I would do it like so for someone looking for more context/understanding of all I want to do:
def reveal_via_forward_proxy(tokenized_data):
r = requests.post(
'https://httpbin.org/post',
data=tokenized_data,
headers={"Content-type": "application/json"},
proxies={"https": "https://{}:{}@{}".format(username, password, forward_proxy)},
verify='cert.pem'
)
assert r.status_code == 200
return r.json()['data']