Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The recommended approach is to create a unique self-signed certificate for each distinct API client. See https://docs.microsoft.com/en-us/powershell/module/pkiclient/new-selfsignedcertificate for information on creating self-signed certificates in Windows. We recommend setting the subject name of the certificate to a value which can identify the consumer (user name, machine name, etc.).

...

Info

Some users have had issues using the above method (specifically the inability to export the certificate). The image below shows an alternate method for generating and exporting both certificates (one with a PK (pfx) and one without (cer)).

Image Added

Once you have run the Powershell command, you will find the new certificate in your Personal folder of the Local machine store.

...

Code Block
languagec#
using System;
using System.Security.Cryptography.X509Certificates;
using Connexion.Core.WebApiApi;

namespace CxnApiClient
{
    class Program
    {
        static async Task Main(string[] args)
        {
            // load the certificate to pass to the gateway api
            var certificate = new X509Certificate2(@"c:\test\apicert.pfx", "foobar");

            // create a proxy to Connexion
            using (var proxy = ConnexionApiProxyFactory.CreateProxy("127.0.0.1", 8089, certificate))
            {
                // test the connection
                Console.WriteLine("Query Groups...");
                var response = await proxy.ServiceMethods.GetGroupsAndTabsAsync(new GetGroupsAndTabsRequest(true));
                foreach (var group in response.Groups)
                {
                    Console.WriteLine(group.Name);
                    foreach (var tab in group.Tabs)
                    {
                        Console.WriteLine($"-->{tab.Name}");
                    }
                }
            }

            Console.ReadLine();
        }
    }
}

At this point, you can now make API calls.

Sample projects:

View file
nameConnexionGatewayApiTest.zip