404 returned when attempting to access service metadata
-
I have a web service(using wsHttpBinding and SSL) developed in Visual Studio 2017. Whenever i introduce the following line, the Web Service just fails and it goes into the "faulted" state.
The error message when attempting to "Add Service Reference" on the client side i recieve the following error: "There was an error downloading 'https://localhost/FootballService/service'. The request failed with HTTP status 404: Not Found. Metadata contains a reference that cannot be resolved: 'https://localhost/FootballService/service'. There was no endpoint listening at https://localhost/FootballService/service that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details. The remote server returned an error: (404) Not Found. If the service is defined in the current solution, try building the solution and adding the service reference again. Here is the code relating to the validator.
public class AuthenticationCertificateValidator : X509CertificateValidator
{
string allowedIssuerName;public AuthenticationCertificateValidator(string allowedIssuerName)
{
if (allowedIssuerName == null)
{
throw new ArgumentNullException("allowedIssuerName");
}this.allowedIssuerName = allowedIssuerName;
}
public override void Validate(X509Certificate2 certificate)
{
// Check that there is a certificate.
if (certificate == null)
{
throw new ArgumentNullException("certificate");
}// Check that the certificate issuer matches the configured issuer. if (allowedIssuerName != certificate.IssuerName.Name) { throw new SecurityTokenValidationException ("Certificate was not issued by a trusted issuer"); }
}
}However the service works fine when i only have the "ChainTrust" line enabled as shown below:
Ideally i want my service and client to use ChainTrust and also use the custom validator class if that's possible? Therefore what am i doing wrong regarding configuration? Am i missing something from the config file? Here is the full Service config: