X509CertificateValidationMode in .NET 4.5

Sponsored by #native_company#
#native_desc# #native_cta#

I'm setting up a service using .NET 4.5 to run with a new app we're writing which uses X509CertificateValidationMode:

client.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;

This service was build in .NET 4.0, where that enumeration exists in System.ServiceModel.Security. However, I was getting compilation errors when trying to access that enumeration, even though I was referencing System.ServiceModel.Security.

What was really odd was that if I changed my project to use .NET 4.0, I didn't get any compilation errors anymore.

Some googling lead to this Microsoft Connect issue, which says that as of .NET 4.5, X509CertificateValidationMode is in System.IdentityModel. Including that DLL in my project allowed it to compile.

Hopefully this helps someone else that has this issue.

Happy Coding!

Matthew Jones

Matthew Jones

I'm a parent, a husband, a geek, a web developer, and a speaker, in roughly that order.

Read More
X509CertificateValidationMode in .NET 4.5
Share this