WCF NETCORE ERROR, Unable to create an SSL/TLS secure channel
I'm trying to connect to a Web Service with two-way ssl auth, I've installed the certificates to consume, in the browser in the browser asks me for the certificate and then access the web service photo: accessing the web service from the browser.
but when i try add the reference to a class library project in WCF Reference trow me this message: An error occurred while attempting to find services at 'https://ws.interbanking.com.ar/ws/ConsultaCuentaClienteService?wsdl'. Request cancelled: Unable to create an SSL/TLS secure channel.
Photo: error message in vs
I tried to download the file that I generated the browser when I give it the certificate and convert it to wsdl and add it but it did not work
any solution?
do you know?
how many words do you know
See also questions close to this topic
-
Fluent Validation with conditions in asp.net core
I am working in asp. net core 6.0 web API project (clean architecture (CQRS)).
I am using fluent validation for validate command and queries.
public class CreateSiteDestinationSectionsCommand : IRequest<x> { public int DestinationSectionId { get; set; } public int DestinationSectionTitleId { get; set; } public int SiteCodeId { get; set; } public string Description { get; set; } public List<DestinationImageDto> Images { get; set; } public List<string> Links { get; set; } }
This is i did inside CreateSiteDestinationSectionsCommandHandler.
var DestinationSectionTitleId = request.DestinationSectionTitleId; if (DestinationSectionTitleId != 10) { if (DestinationSectionTitleId == 1 || DestinationSectionTitleId == 2 || DestinationSectionTitleId == 5 || DestinationSectionTitleId == 7 || DestinationSectionTitleId == 8 || DestinationSectionTitleId == 9 || DestinationSectionTitleId == 11) { var sectionimageCount = request.Images.Count; if (sectionimageCount != 1) { throw new ApiValidationException("Section has not more than one image"); } else (DestinationSectionTitleId == 10 && request.Images != null) { var sectionimageCount = request.Images.Count; if (sectionimageCount != 0) { throw new ApiValidationException("Section doesnot have any image"); } } } }
But instead of handling validation inside commandHandler, I have to handle validation in CreateSiteDestinationSectionsCommandValidator.
I tried this,
RuleFor(x => x.Images) .Must(x => x != null) .When(x => x.DestinationSectionId != 10) .WithMessage("Site Section image required"); RuleFor(x => x.DestinationSectionId).NotEmpty(); RuleFor(x => x.Images) .Must(x => x.Count != 1) .When(x => x.DestinationSectionId == 1 && x.DestinationSectionId == 1 && x.DestinationSectionId == 2 && x.DestinationSectionId == 5 && x.DestinationSectionId == 7 && x.DestinationSectionId == 8 && x.DestinationSectionId == 9 && x.DestinationSectionId == 11 ) .WithMessage("Site Section has not more than one image"); }
When I check throug postman request, Even I send with DestinationSectionId = 10 (and not sending any images), I got validation error as
"errors": { "Images": [ "Site Section image required" ] }
And Even I send more than 1 images for DestinationSectionId = 1, I did not get validation error. BUT I shoud get validation error as
Site Section has not more than one image
Why this validations not work correctly? What I missed?
-
Using RestSharp to request a file fails with memory issue
I have to API's talking to each other on Kubernetes. The first API asks the second API for a small file using RestSharp (in ASP.NET). The file is 8Kb so basically not large at all.
Yet i get the following message on the API that wants to receive the file:
Exception of type 'System.OutOfMemoryException' was thrown. at RestSharp.RestClient.ThrowIfError(RestResponse response) at RestSharp.RestClientExtensions.GetAsync(RestClient client, RestRequest request, CancellationToken cancellationToken) at Aftermarket.Server.AdministrationService.Server.Services.Services.RunSessionService.DownloadRunSession(String foldername) in /src/Aftermarket.Server.DbApi/Server/Services/Services/RunSessionService.cs:line 59
The code U use to call the other API and ask for the file looks as follows:
public async Task<byte[]> DownloadRunSession(string foldername) { try { var request = new RestRequest($"{config["WebApiServer:WebApiServerUrl"]}/blob/{foldername}"); var response = await client.GetAsync(request); if (!response.IsSuccessful) { Console.WriteLine("File download failed"); Console.WriteLine(response.StatusCode); return null; } return response.RawBytes; }catch(Exception e) { Console.WriteLine(e.Message); Console.WriteLine(e.StackTrace); return null; } }
The API that responds by sending the file has the following controller method:
public IActionResult GetBlob([FromQuery] string folderName, [FromServices] GetBlobsService _getBlobsService) { _logger.Info(folderName); Guid guid = Guid.NewGuid(); if (_env.EnvironmentName == "dev" || _env.EnvironmentName == "prod") { byte[] blob = _getBlobsService.GetBlob(folderName, guid, _logger); if (blob == null) return this.NotFound(); else { return File(blob, "application/force-download", guid + ".zip"); } } else { return Content("This function is only available in Dev/Uat Environment"); } }
Any one have any idea how a 8Kb file is causing this issue?
-
How is Windows Authentication Wired Up?
I'm in the process of creating an ASPNET Core 6 MVC app in VS 2022 which will eventually be deployed in a Docker container. Windows Authentication will be used as it's an internal app. When creating this project from scratch with File -> New Project -> ASP.NET Core 6 Web App (Model-View-Controller) and with Windows Authentication enabled, everything works as expected.
This is where it gets weird. Since this will be a Docker container on Linux, I commented out the IIS settings in launchSettings.json.
{ //"iisSettings": { // "windowsAuthentication": true, // "anonymousAuthentication": false, // "iisExpress": { // "applicationUrl": "http://localhost:60583", // "sslPort": 44391 // } //}, "profiles": { "ASPNETCORE6": { "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": true, "applicationUrl": "https://localhost:7276;http://localhost:5276", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } }, "IIS Express": { "commandName": "IISExpress", "launchBrowser": true, "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } } } }
To recreate this issue, comment out the following from the generated Program.cs file:
//using Microsoft.AspNetCore.Authentication.Negotiate; //builder.Services.AddAuthentication(NegotiateDefaults.AuthenticationScheme) // .AddNegotiate(); //builder.Services.AddAuthorization(options => //{ // options.FallbackPolicy = options.DefaultPolicy; //}); //app.UseAuthentication(); //app.UseAuthorization();
Now, when I run a debugging session using IIS Express, the browser windows renders with my correct domain name being displayed. How is this even possible? Is something being cached? Also, the browser is going to http://localhost:44391/ when debugging with IIS Express even though this is commented out in launchSettings.json.
Note: Windows authentication is not working when I debug with Kestrel, which is what I would expect.
-
Connection via REST API to Azure DevOps fails
I am currently working on a REST API to be able to call a WCF service via it. Now I have the problem when I try to call up tasks via Azure DevOps using this method,
<OperationContract()> <WebGet(UriTemplate:="/todos?user={sUser}&projectID={lProjektID}", BodyStyle:=WebMessageBodyStyle.Wrapped, RequestFormat:=WebMessageFormat.Json, ResponseFormat:=WebMessageFormat.Json)> Function GetTodos(Optional ByVal sUser As String = "%", Optional ByVal lProjektID As Long = Nothing) As List(Of ProjektToDo)
I get these exceptions after trying to connect to Azure Devops at this:
Dim creds As New VssBasicCredential(String.Empty, _DevOpsPAT) Dim connection As VssConnection = New VssConnection(New Uri(My.Settings.TFSBasisUrlSSL), creds) 'Create instance of WorkItemTrackingHttpClient using VssConnection Dim witClient As WorkItemTrackingHttpClient = connection.GetClient(Of WorkItemTrackingHttpClient) 'This connection fails !' Dim queryHierarchyItems As List(Of QueryHierarchyItem) = witClient.GetQueriesAsync(Projekt,, 2).Result
- "System.Net.Sockets.SocketException" in System.dll
- "System.IO.IOException" in System.dll
- "System.ObjectDisposedException" in System.dll
- "System.Net.WebException" in System.dll
- "System.Net.Http.HttpRequestException" in Microsoft.VisualStudio.Services.Common.dll
- "System.Net.Http.HttpRequestException" in mscorlib.dll.
- The InnerException of the ex.Message tells me "An existing connection was closed by the remote host" Message: "Unable to read data from the transfer connection". I'm currently training in a new company and have no experience in the area of Rest API and WCF Service, please help me I'm desperate about this task because I just don't know where to start.
-
WCF Consume WS-Security
I am trying to consume a soap service that uses ws-security, the project runs fine in the soap UI, but at the code level I cannot receive the request, I have used WCF but it has worked, here is an example of the consumption:
WCF CONSUME
<?xml version="1.0" encoding="utf-8"?> <configuration> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/> </startup> <system.serviceModel> <bindings> <customBinding> <binding name="ServicioMotorPortSoapBinding"> <textMessageEncoding messageVersion="Soap11"/> <security authenticationMode="UserNameOverTransport" enableUnsecuredResponse="true" allowSerializedSigningTokenOnReply="true" messageSecurityVersion="WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10" includeTimestamp="false"> </security> <httpsTransport /> </binding> </customBinding> </bindings> <client> <endpoint address="https://demo-servicesesb.datacredito.com.co:443/wss/DecisorWS/services/MotorService" binding="customBinding" bindingConfiguration="ServicioMotorPortSoapBinding" contract="dataCreditoGYF.MotorService" name="ServicioMotorPort.dmz.https" > <identity> <dns value="demo-servicesesb.datacredito.com.co"/> </identity> </endpoint> </client> </configuration> //Using Binding on code var myBinding = new CustomBinding("ServicioMotorPortSoapBinding"); var endPoint = new EndpointAddress(new Uri(url), EndpointIdentity.CreateDnsIdentity("wtst03.girosyfinanzas.com")); ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; //ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12; MotorServiceClient objeto = new MotorServiceClient(myBinding, endPoint); //objeto.ChannelFactory.Open(); objeto.ClientCredentials.UserName.UserName = "2-860006797"; objeto.ClientCredentials.UserName.Password = "Giros123"; //Obtengo Certificado del cliente objeto.ClientCredentials.ClientCertificate.SetCertificate( StoreLocation.CurrentUser, StoreName.My, X509FindType.FindBySubjectName, "wtst03.girosyfinanzas.com"); objeto.ClientCredentials.ServiceCertificate.SetDefaultCertificate( StoreLocation.CurrentUser, StoreName.My, X509FindType.FindBySubjectName, "wtst03.girosyfinanzas.com"); objeto.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = System.ServiceModel.Security.X509CertificateValidationMode.None; solicitud soapRequest = new solicitud(); executeStrategyRequest some_ = new executeStrategyRequest(); // I fill the body using object soapRequest. some_.solicitud = soapRequest; //I make the request var x = objeto.executeStrategy(some_.solicitud);
After do the request I got an error could not establish trust relationship for the ssl/tls secure channel, can anyone, tell what's it's missing?, or if i can use other tool for the consume.
-
How to install a custom certificate in Symfony server?
With
server:ca:install
on the Symfony console an SSL certificate can be generated and installed.Is it possible / How to install an existing one, created separately (instead of the auto-generated one)?
Background: I need a certificate, that contains a specific IP as "alternative name".
-
Understanding certificate revocation configuration (crl.cnf/openssl.cnf) file
I have a crl.cnf as below:
[ ca ] default_ca = CA_default # The default ca section #################################################################### [ CA_default ] dir = _CA_dir_ database = _index_fname_ # database index file. # Comment out the following two lines for the "traditional" # (and highly broken) format. name_opt = ca_default # Subject Name options cert_opt = ca_default # Certificate field options
In the above file, What does CA_dir , index_fname and ca_default variables refer to or how to find what values those variables hold? It would be really helpful if someone helps me to understand this. Thanks in advance!
-
Open Browser with a specific url on sending request on API (.Net core MVC)
Working on .Net Core MVC and IText7, I'm filling a Pdf form (empty form PDF is already saved on server). What I want is, Whenever I send request to the link (can be a API endpoint), it should forces my browser to open the pdf on it. Opening the Pdf is already achieved by the writing the header of the response with pdf file and also the write content-disposition to the header but the main problem is: How I can force my browser to be opened on sending a request to the .Net Core Application or .Net Core API?
-
Consuming WCF service from aspnet core application using protoobuf
My existing netfx library allows consuming a vendor side WCF service. The payload size and frequency at which the call is made is pretty high. So we use protobuf (2.0.0.668). Essentially what we do is apply
ProtoBuf.ServiceModel.ProtoEndpointBehavior
to the client (in code).We are in the process of migrating the library to aspnet core (multi-target to net461 and netcoreapp3.1, and net6.0 in future). Can I still continue to use protobuf. If yes, then how?
BTW, we do allow consuming WCF endpoints from NETCore apps.
-
BizTalk Send Port : (413) Request Entity Too Large. The page was not displayed because the request entity is too large
We have a WCF Service hosted on IIS 10, We have a send Port WCF-Custom(BasicHttpBinding) through which I am sending an excel file by converting to Base64 format in a pipeline.
If I send the same message to a folder using File adapter there is no issue but while using WCF-Custom(BasicHttpBinding) I am getting below error "System.Net.WebException: The remote server returned an unexpected response: (413) Request Entity Too Large. The page was not displayed because the request entity is too large."
Note: My file size is 37MB, so tried setting up max for all the attributes, I have checked Binding name also.
Can Anyone have any Solutions, how can I resolve this issue?
-
Unable to set sslProtocol in app.config on NET Framework 4.8
I am trying to configure a WCF service through the app.config file so it defaults to getting the TLS settings from the OS (we want the service to use TLS 1.2 as default, actually), and I am trying to follow the Transport Layer Security (TLS) best practices with the .NET Framework article.
But when I try to add the sslProtocols parameter to the transport attribute, it seems like it does not exist.
Do we lack some Assembly or other dependencies? Did it change from NET Framework 4.8?
Our config file is as follows:
<?xml version="1.0" encoding="utf-8"?> <configuration> <system.serviceModel> <bindings> <basicHttpBinding> <binding name="siiBinding"> <security mode="Transport"/> </binding> <binding name="siiBinding1"> <security mode="Transport"/> </binding> <binding name="siiBinding2"> <security mode="Transport"/> </binding> <binding name="siiBinding3"/> </basicHttpBinding> </bindings> <client> <endpoint address="https://www1.agenciatributaria.gob.es/wlpl/SSII-FACT/ws/fe/SiiFactFEV1SOAP" binding="basicHttpBinding" bindingConfiguration="siiBinding" contract="SuministroFactEmitidasReference.siiSOAP" name="SuministroFactEmitidas"/> <endpoint address="https://www10.agenciatributaria.gob.es/wlpl/SSII-FACT/ws/fe/SiiFactFEV1SOAP" binding="basicHttpBinding" bindingConfiguration="siiBinding1" contract="SuministroFactEmitidasReference.siiSOAP" name="SuministroFactEmitidasSello"/> <endpoint address="https://www7.aeat.es/wlpl/SSII-FACT/ws/fe/SiiFactFEV1SOAP" binding="basicHttpBinding" bindingConfiguration="siiBinding2" contract="SuministroFactEmitidasReference.siiSOAP" name="SuministroFactEmitidasPruebas"/> </client> </system.serviceModel> <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/></startup></configuration>