public HttpHandler(ILoggerFactory loggerFactory, NorthApiOptions options)
        {
            _logger  = loggerFactory?.CreateLogger(typeof(HttpHandler));
            _options = options;

            Verify();

            var handler = new HttpClientHandler
            {
                ClientCertificateOptions = ClientCertificateOption.Manual,
                SslProtocols             = SslProtocols.Tls12,
                ServerCertificateCustomValidationCallback = (x, y, z, m) => true,
            };

            handler.ClientCertificates.Add(new X509Certificate2(_options.Cert.Path, _options.Cert.Password));
            _httpClient = new HttpClient(handler);
        }
Пример #2
0
 public Urls(NorthApiOptions options)
 {
     Login                = $"{options.BaseUrl}/iocm/app/sec/v1.1.0/login";
     RefreshToken         = $"{options.BaseUrl}/iocm/app/sec/v1.1.0/refreshToken";
     DeviceRegister       = $"{options.BaseUrl}/iocm/app/reg/v1.1.0/deviceCredentials";
     DeviceRegisterForPwd = $"{options.BaseUrl}/iocm/app/reg/v2.0.0/deviceCredentials";
     DeviceRefresh        = $"{options.BaseUrl}/iocm/app/reg/v1.1.0/deviceCredentials";
     DeviceModify         = $"{options.BaseUrl}/iocm/app/dm/v1.4.0/devices";
     DeviceDelete         = $"{options.BaseUrl}/iocm/app/dm/v1.4.0/devices";
     DeviceActivated      = $"{options.BaseUrl}/iocm/app/reg/v1.1.0/deviceCredentials";
     DeviceGet            = $"{options.BaseUrl}/iocm/app/dm/v1.4.0/devices";
     DeviceQuery          = $"{options.BaseUrl}/iocm/app/dm/v1.4.0/devices";
     DeviceDataHistory    = $"{options.BaseUrl}/iocm/app/data/v1.2.0/deviceDataHistory";
     Subscribe            = $"{options.BaseUrl}/iocm/app/sub/v1.2.0/subscriptions";
     SubscriptionGet      = $"{options.BaseUrl}/iocm/app/sub/v1.2.0/subscriptions";
     SubscriptionQuery    = $"{options.BaseUrl}/iocm/app/sub/v1.2.0/subscriptions";
     SubscriptionDelete   = $"{options.BaseUrl}/iocm/app/sub/v1.2.0/subscriptions";
     SubscribeManage      = $"{options.BaseUrl}/iodm/app/sub/v1.1.0/subscribe";
     CommandCreate        = $"{options.BaseUrl}/iocm/app/cmd/v1.4.0/deviceCommands";
     CommandQuery         = $"{options.BaseUrl}/iocm/app/cmd/v1.4.0/deviceCommands";
     CommandCancel        = $"{options.BaseUrl}/iocm/app/cmd/v1.4.0/deviceCommands/";
 }