Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

.net core console application forbidden access to https://..., a certificate is required

$
0
0

Hi pals,

I have a .net core console application and want to make a call to an API, hosted on an SSL-enabled endpoint. I have installed the certificate on my local machine, but still cannot call the api! I get the error "forbidden access tohttps://..., a certificate is required" How should I solve the issue? All previous issues regarding SSL I googled, are about asp.net core web app, whereas I have a .net core console app.

Parts of the code is here. I use RavenDb for my repository. The problem is that the raven server is hosted an SSL-based endpoint and I cannot get connected to it!

public static DocumentStore RavenDocumentStore { get; set; }
public static IEducationService EducationService { get; set; }

static async Task Main(string[] args)
{
            try
            {
				
				InitializeDatabases();
				InitializeService();
				
               var edu = new Education {
				   Id = 1,
				   Title = "Software Engineering"
			   };
			   await EducationService.AddAsync(edu);
               await EducationService.SaveChangesAsync();
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception: " + e.Message);
            }

}
		
public static void InitializeDatabases()
{
            try
            {
                TbsContext = new TbsContext();
                RavenDocumentStore = new DocumentStore
                {
                    Urls = new[] { "https://someserver.com" },
                    Database = "test",
                    Conventions =
                    {
                        MaxNumberOfRequestsPerSession = int.MaxValue,
                    }
                };

                RavenDocumentStore.Initialize();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                Logger.ErrorException(ex.Message, ex);
                throw;
            }
}		
		
private static void InitializeServices()
{
            try
            {
		var ravenAsyncSession = RavenDocumentStore.OpenAsyncSession();
				
                var educationRepository = new EducationRepository(ravenAsyncSession);
                EducationService = new EducationService(educationRepository);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                Logger.ErrorException(ex.Message, ex);
                throw;
            }
}		

Thanks in advance


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>