why certificates are null using .NET Core 2 but it works just fine with .NET Framework 4.6.2?Django Authentication from .NET using HttpWebRequest and HttpWebResponse via HTTP POSTUnable to set cookies with web browser controls in windows phone appReferencing .net framework assemblies in .net core 2 that rely on the ConfigurationManagerIs there anyway to use a third-party library that has been created for .NET Framework, in .NET Core 2.0?.Net Core 2.0 Log4Net AdoNetAppender isn't workingWhy doesn't garbage collector in net core 2.0 free all memory.Net Core 2.0 solution with .Net Framework project dependencies - Could not load file or assembly 'System.ServiceModel'How to track in Entry Framework that Record has been created successfully .NET Core 2.0.Net Core 2.0 Webservice and TLS 1.2/certificate.HttpContext.Features.Get<IHttpResponseFeature>().ReasonPhrase is not working in .net core 2.1?
Has J.J.Jameson ever found out that Peter Parker is Spider-Man?
Is the "muddled thoughts" from Synaptic Static a magical effect?
(7 of 11: Fillomino) What is Pyramid Cult's Favorite Shape?
Where can I see modifications made to the PATH environment variable by the Go installer
On the expression "sun-down"
How were x-ray diffraction patterns deciphered before computers?
Skipping same old introductions
Does the problem of P vs NP come under the category of Operational Research?
Difference between "jail" and "prison" in German
How does shared_ptr<void> know which destructor to use?
Why isn't the new LEGO CV joint available on Bricklink or Brickowl?
Phase portrait of a system of differential equations
how to change ^L code in many files in ubuntu?
Password management for kids - what's a good way to start?
Can I say "Gesundheit" if someone is coughing?
Why are sugars in whole fruits not digested the same way sugars in juice are?
Astable 555 circuit not oscillating
Can an unintentional murderer leave Ir Miklat for Shalosh Regalim?
Search and replace a substring only if another substring is not present
Does proof-of-work contribute directly to prevent double-spending?
Partial Fractions: Why does this shortcut method work?
Why adjustbox needs a tweak of raise=-0.3ex with enumitem?
Gold Battle KoTH
Can you shove a friendly creature?
why certificates are null using .NET Core 2 but it works just fine with .NET Framework 4.6.2?
Django Authentication from .NET using HttpWebRequest and HttpWebResponse via HTTP POSTUnable to set cookies with web browser controls in windows phone appReferencing .net framework assemblies in .net core 2 that rely on the ConfigurationManagerIs there anyway to use a third-party library that has been created for .NET Framework, in .NET Core 2.0?.Net Core 2.0 Log4Net AdoNetAppender isn't workingWhy doesn't garbage collector in net core 2.0 free all memory.Net Core 2.0 solution with .Net Framework project dependencies - Could not load file or assembly 'System.ServiceModel'How to track in Entry Framework that Record has been created successfully .NET Core 2.0.Net Core 2.0 Webservice and TLS 1.2/certificate.HttpContext.Features.Get<IHttpResponseFeature>().ReasonPhrase is not working in .net core 2.1?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have been doing some test migrating .NET Framework 4.6.2 apps to .NET Core 2. I noticed that this particular app, a monitoring http is not working fine with Net Core 2. Can you please help me to verify what is happening?
static void Main(string[] args)
try
HttpWebRequest myhttpWebReqest = (HttpWebRequest)WebRequest.Create("https://www.google.com.mx/");
System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch();
timer.Start();
HttpWebResponse myHttpWebResponse = (HttpWebResponse)myhttpWebReqest.GetResponse();
timer.Stop();
TimeSpan timeSpan = timer.Elapsed;
Console.WriteLine(timeSpan.ToString());
Console.WriteLine();
Console.WriteLine(myHttpWebResponse.StatusCode);
Console.WriteLine((int)myHttpWebResponse.StatusCode);
Console.WriteLine();
Console.WriteLine(myhttpWebReqest.ServicePoint.Certificate.GetEffectiveDateString());
Console.WriteLine();
Console.WriteLine(myhttpWebReqest.ServicePoint.Certificate.GetExpirationDateString());
Console.WriteLine();
Console.WriteLine(myhttpWebReqest.ServicePoint.Certificate.Issuer);
Console.WriteLine();
Console.WriteLine(myhttpWebReqest.ServicePoint.Certificate.Subject);
catch (Exception ex)
Console.WriteLine(ex.Message);
if(ex.InnerException !=null)
Console.WriteLine(ex.InnerException);
Console.ReadLine();
}
in the .NET Framework 4.6.2 i see the certificate data, in the .NET Core 2 i see myhttpWebReqest.ServicePoint.Certificate null ... do you know why?
httpwebrequest .net-core-2.0 system.net.httpwebrequest
add a comment |
I have been doing some test migrating .NET Framework 4.6.2 apps to .NET Core 2. I noticed that this particular app, a monitoring http is not working fine with Net Core 2. Can you please help me to verify what is happening?
static void Main(string[] args)
try
HttpWebRequest myhttpWebReqest = (HttpWebRequest)WebRequest.Create("https://www.google.com.mx/");
System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch();
timer.Start();
HttpWebResponse myHttpWebResponse = (HttpWebResponse)myhttpWebReqest.GetResponse();
timer.Stop();
TimeSpan timeSpan = timer.Elapsed;
Console.WriteLine(timeSpan.ToString());
Console.WriteLine();
Console.WriteLine(myHttpWebResponse.StatusCode);
Console.WriteLine((int)myHttpWebResponse.StatusCode);
Console.WriteLine();
Console.WriteLine(myhttpWebReqest.ServicePoint.Certificate.GetEffectiveDateString());
Console.WriteLine();
Console.WriteLine(myhttpWebReqest.ServicePoint.Certificate.GetExpirationDateString());
Console.WriteLine();
Console.WriteLine(myhttpWebReqest.ServicePoint.Certificate.Issuer);
Console.WriteLine();
Console.WriteLine(myhttpWebReqest.ServicePoint.Certificate.Subject);
catch (Exception ex)
Console.WriteLine(ex.Message);
if(ex.InnerException !=null)
Console.WriteLine(ex.InnerException);
Console.ReadLine();
}
in the .NET Framework 4.6.2 i see the certificate data, in the .NET Core 2 i see myhttpWebReqest.ServicePoint.Certificate null ... do you know why?
httpwebrequest .net-core-2.0 system.net.httpwebrequest
question is also here
– David Alejandro García García
Apr 9 at 20:05
Why are you using HttpWebRequest at all? Even in 4.6.2 the preferred way is to use HttpClient. HttpClient uses handlers to configure retries, compression, certificates
– Panagiotis Kanavos
Apr 18 at 15:53
add a comment |
I have been doing some test migrating .NET Framework 4.6.2 apps to .NET Core 2. I noticed that this particular app, a monitoring http is not working fine with Net Core 2. Can you please help me to verify what is happening?
static void Main(string[] args)
try
HttpWebRequest myhttpWebReqest = (HttpWebRequest)WebRequest.Create("https://www.google.com.mx/");
System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch();
timer.Start();
HttpWebResponse myHttpWebResponse = (HttpWebResponse)myhttpWebReqest.GetResponse();
timer.Stop();
TimeSpan timeSpan = timer.Elapsed;
Console.WriteLine(timeSpan.ToString());
Console.WriteLine();
Console.WriteLine(myHttpWebResponse.StatusCode);
Console.WriteLine((int)myHttpWebResponse.StatusCode);
Console.WriteLine();
Console.WriteLine(myhttpWebReqest.ServicePoint.Certificate.GetEffectiveDateString());
Console.WriteLine();
Console.WriteLine(myhttpWebReqest.ServicePoint.Certificate.GetExpirationDateString());
Console.WriteLine();
Console.WriteLine(myhttpWebReqest.ServicePoint.Certificate.Issuer);
Console.WriteLine();
Console.WriteLine(myhttpWebReqest.ServicePoint.Certificate.Subject);
catch (Exception ex)
Console.WriteLine(ex.Message);
if(ex.InnerException !=null)
Console.WriteLine(ex.InnerException);
Console.ReadLine();
}
in the .NET Framework 4.6.2 i see the certificate data, in the .NET Core 2 i see myhttpWebReqest.ServicePoint.Certificate null ... do you know why?
httpwebrequest .net-core-2.0 system.net.httpwebrequest
I have been doing some test migrating .NET Framework 4.6.2 apps to .NET Core 2. I noticed that this particular app, a monitoring http is not working fine with Net Core 2. Can you please help me to verify what is happening?
static void Main(string[] args)
try
HttpWebRequest myhttpWebReqest = (HttpWebRequest)WebRequest.Create("https://www.google.com.mx/");
System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch();
timer.Start();
HttpWebResponse myHttpWebResponse = (HttpWebResponse)myhttpWebReqest.GetResponse();
timer.Stop();
TimeSpan timeSpan = timer.Elapsed;
Console.WriteLine(timeSpan.ToString());
Console.WriteLine();
Console.WriteLine(myHttpWebResponse.StatusCode);
Console.WriteLine((int)myHttpWebResponse.StatusCode);
Console.WriteLine();
Console.WriteLine(myhttpWebReqest.ServicePoint.Certificate.GetEffectiveDateString());
Console.WriteLine();
Console.WriteLine(myhttpWebReqest.ServicePoint.Certificate.GetExpirationDateString());
Console.WriteLine();
Console.WriteLine(myhttpWebReqest.ServicePoint.Certificate.Issuer);
Console.WriteLine();
Console.WriteLine(myhttpWebReqest.ServicePoint.Certificate.Subject);
catch (Exception ex)
Console.WriteLine(ex.Message);
if(ex.InnerException !=null)
Console.WriteLine(ex.InnerException);
Console.ReadLine();
}
in the .NET Framework 4.6.2 i see the certificate data, in the .NET Core 2 i see myhttpWebReqest.ServicePoint.Certificate null ... do you know why?
httpwebrequest .net-core-2.0 system.net.httpwebrequest
httpwebrequest .net-core-2.0 system.net.httpwebrequest
asked Mar 27 at 1:26
David Alejandro García GarcíaDavid Alejandro García García
778 bronze badges
778 bronze badges
question is also here
– David Alejandro García García
Apr 9 at 20:05
Why are you using HttpWebRequest at all? Even in 4.6.2 the preferred way is to use HttpClient. HttpClient uses handlers to configure retries, compression, certificates
– Panagiotis Kanavos
Apr 18 at 15:53
add a comment |
question is also here
– David Alejandro García García
Apr 9 at 20:05
Why are you using HttpWebRequest at all? Even in 4.6.2 the preferred way is to use HttpClient. HttpClient uses handlers to configure retries, compression, certificates
– Panagiotis Kanavos
Apr 18 at 15:53
question is also here
– David Alejandro García García
Apr 9 at 20:05
question is also here
– David Alejandro García García
Apr 9 at 20:05
Why are you using HttpWebRequest at all? Even in 4.6.2 the preferred way is to use HttpClient. HttpClient uses handlers to configure retries, compression, certificates
– Panagiotis Kanavos
Apr 18 at 15:53
Why are you using HttpWebRequest at all? Even in 4.6.2 the preferred way is to use HttpClient. HttpClient uses handlers to configure retries, compression, certificates
– Panagiotis Kanavos
Apr 18 at 15:53
add a comment |
1 Answer
1
active
oldest
votes
See discussion of this here: https://github.com/dotnet/corefx/issues/36979
ServicePointManager and ServicePoint classes are no-op on .NET Core. But you can do a similar thing with HttpClient. HttpClient is the more modern and preferred HTTP API in .NET Framework and .NET Core.
using System;
using System.Net.Http;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
namespace NetCoreConsoleApp1
class Program
static void Main(string[] args)
var handler = new HttpClientHandler();
handler.ServerCertificateCustomValidationCallback = CustomCallback;
var client = new HttpClient(handler);
HttpResponseMessage response = client.GetAsync("https://www.google.com.mx/").GetAwaiter().GetResult();
Console.WriteLine(response.StatusCode);
Console.WriteLine((int)response.StatusCode);
private static bool CustomCallback(HttpRequestMessage arg1, X509Certificate2 arg2, X509Chain arg3, SslPolicyErrors arg4)
Console.WriteLine(arg2.GetEffectiveDateString());
Console.WriteLine(arg2.GetExpirationDateString());
Console.WriteLine(arg2.Issuer);
Console.WriteLine(arg2.Subject);
return arg4 == SslPolicyErrors.None;
thank you David - MSFT. aparently HttpWebRequest API is obsolete now. more details HERE
– David Alejandro García García
May 3 at 4:14
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55368470%2fwhy-certificates-are-null-using-net-core-2-but-it-works-just-fine-with-net-fra%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
See discussion of this here: https://github.com/dotnet/corefx/issues/36979
ServicePointManager and ServicePoint classes are no-op on .NET Core. But you can do a similar thing with HttpClient. HttpClient is the more modern and preferred HTTP API in .NET Framework and .NET Core.
using System;
using System.Net.Http;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
namespace NetCoreConsoleApp1
class Program
static void Main(string[] args)
var handler = new HttpClientHandler();
handler.ServerCertificateCustomValidationCallback = CustomCallback;
var client = new HttpClient(handler);
HttpResponseMessage response = client.GetAsync("https://www.google.com.mx/").GetAwaiter().GetResult();
Console.WriteLine(response.StatusCode);
Console.WriteLine((int)response.StatusCode);
private static bool CustomCallback(HttpRequestMessage arg1, X509Certificate2 arg2, X509Chain arg3, SslPolicyErrors arg4)
Console.WriteLine(arg2.GetEffectiveDateString());
Console.WriteLine(arg2.GetExpirationDateString());
Console.WriteLine(arg2.Issuer);
Console.WriteLine(arg2.Subject);
return arg4 == SslPolicyErrors.None;
thank you David - MSFT. aparently HttpWebRequest API is obsolete now. more details HERE
– David Alejandro García García
May 3 at 4:14
add a comment |
See discussion of this here: https://github.com/dotnet/corefx/issues/36979
ServicePointManager and ServicePoint classes are no-op on .NET Core. But you can do a similar thing with HttpClient. HttpClient is the more modern and preferred HTTP API in .NET Framework and .NET Core.
using System;
using System.Net.Http;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
namespace NetCoreConsoleApp1
class Program
static void Main(string[] args)
var handler = new HttpClientHandler();
handler.ServerCertificateCustomValidationCallback = CustomCallback;
var client = new HttpClient(handler);
HttpResponseMessage response = client.GetAsync("https://www.google.com.mx/").GetAwaiter().GetResult();
Console.WriteLine(response.StatusCode);
Console.WriteLine((int)response.StatusCode);
private static bool CustomCallback(HttpRequestMessage arg1, X509Certificate2 arg2, X509Chain arg3, SslPolicyErrors arg4)
Console.WriteLine(arg2.GetEffectiveDateString());
Console.WriteLine(arg2.GetExpirationDateString());
Console.WriteLine(arg2.Issuer);
Console.WriteLine(arg2.Subject);
return arg4 == SslPolicyErrors.None;
thank you David - MSFT. aparently HttpWebRequest API is obsolete now. more details HERE
– David Alejandro García García
May 3 at 4:14
add a comment |
See discussion of this here: https://github.com/dotnet/corefx/issues/36979
ServicePointManager and ServicePoint classes are no-op on .NET Core. But you can do a similar thing with HttpClient. HttpClient is the more modern and preferred HTTP API in .NET Framework and .NET Core.
using System;
using System.Net.Http;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
namespace NetCoreConsoleApp1
class Program
static void Main(string[] args)
var handler = new HttpClientHandler();
handler.ServerCertificateCustomValidationCallback = CustomCallback;
var client = new HttpClient(handler);
HttpResponseMessage response = client.GetAsync("https://www.google.com.mx/").GetAwaiter().GetResult();
Console.WriteLine(response.StatusCode);
Console.WriteLine((int)response.StatusCode);
private static bool CustomCallback(HttpRequestMessage arg1, X509Certificate2 arg2, X509Chain arg3, SslPolicyErrors arg4)
Console.WriteLine(arg2.GetEffectiveDateString());
Console.WriteLine(arg2.GetExpirationDateString());
Console.WriteLine(arg2.Issuer);
Console.WriteLine(arg2.Subject);
return arg4 == SslPolicyErrors.None;
See discussion of this here: https://github.com/dotnet/corefx/issues/36979
ServicePointManager and ServicePoint classes are no-op on .NET Core. But you can do a similar thing with HttpClient. HttpClient is the more modern and preferred HTTP API in .NET Framework and .NET Core.
using System;
using System.Net.Http;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
namespace NetCoreConsoleApp1
class Program
static void Main(string[] args)
var handler = new HttpClientHandler();
handler.ServerCertificateCustomValidationCallback = CustomCallback;
var client = new HttpClient(handler);
HttpResponseMessage response = client.GetAsync("https://www.google.com.mx/").GetAwaiter().GetResult();
Console.WriteLine(response.StatusCode);
Console.WriteLine((int)response.StatusCode);
private static bool CustomCallback(HttpRequestMessage arg1, X509Certificate2 arg2, X509Chain arg3, SslPolicyErrors arg4)
Console.WriteLine(arg2.GetEffectiveDateString());
Console.WriteLine(arg2.GetExpirationDateString());
Console.WriteLine(arg2.Issuer);
Console.WriteLine(arg2.Subject);
return arg4 == SslPolicyErrors.None;
answered Apr 18 at 15:50
David - MSFTDavid - MSFT
1062 bronze badges
1062 bronze badges
thank you David - MSFT. aparently HttpWebRequest API is obsolete now. more details HERE
– David Alejandro García García
May 3 at 4:14
add a comment |
thank you David - MSFT. aparently HttpWebRequest API is obsolete now. more details HERE
– David Alejandro García García
May 3 at 4:14
thank you David - MSFT. aparently HttpWebRequest API is obsolete now. more details HERE
– David Alejandro García García
May 3 at 4:14
thank you David - MSFT. aparently HttpWebRequest API is obsolete now. more details HERE
– David Alejandro García García
May 3 at 4:14
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55368470%2fwhy-certificates-are-null-using-net-core-2-but-it-works-just-fine-with-net-fra%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
question is also here
– David Alejandro García García
Apr 9 at 20:05
Why are you using HttpWebRequest at all? Even in 4.6.2 the preferred way is to use HttpClient. HttpClient uses handlers to configure retries, compression, certificates
– Panagiotis Kanavos
Apr 18 at 15:53