I want to make a program that takes the backup of my fortigate firewall using C#.
I have created a profile on firewall which has read access of configuration and also generated the API key for same.
Below is my sample code to do that
class Program
{
public static string urlParameters = "?scope=global&access_token=mytoken";//ill replace mytoken with generated token
static void Main(string[] args)
{
HttpClient httpClient = new HttpClient();
httpClient.BaseAddress = new Uri("https://x.x.x.x/api/v2/monitor/system/config/backup/");
HttpResponseMessage responseMessage = httpClient.GetAsync(urlParameters).Result;//Im getting error in this statement
Console.WriteLine(responseMessage.ToString());
}
}
I'm getting below 3 errors executing above code
HttpRequestException: An error occurred while sending the request.
WebException: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.
AuthenticationException: The remote certificate is invalid according to the validation procedure.
I'm able to ping that firewall from system that i'm executing program in.