Jump to content

MatSim

Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Everything posted by MatSim

  1. Hi, first of all thank you for your reply. I have tried your suggestion, but still get the same 401 Unauthorized. Here below the code: System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12 System.Net.ServicePointManager.ServerCertificateValidationCallback = Function(se As Object, cert As System.Security.Cryptography.X509Certificates.X509Certificate, chain As System.Security.Cryptography.X509Certificates.X509Chain, sslerror As System.Net.Security.SslPolicyErrors) True WReq = CType(WebRequest.Create("https://" + ksc_h + ":13299/api/v1.0/Session.StartSession"), HttpWebRequest) ksc_u_b64 = System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(ksc_u)).ToString() ksc_p_b64 = System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(ksc_p)).ToString() ksc_h_b64 = System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(ksc_h)).ToString() WReq.Method = "POST" WReq.ProtocolVersion = HttpVersion.Version11 WReq.ContentType = "application/json" 'WReq.ContentLength = 2 System.Net.ServicePointManager.Expect100Continue = False WReq.Timeout = 12000000 WReq.Headers.Add("Authorization", "KSCBasic user=""" + ksc_u_b64 + """, pass=""" + ksc_p_b64 + """") May the user passed be a domain user or shall it be a kaspesky user o local user of the server? Do you know if I shall enable anything on the security center side? Thanks in advance Mateo
  2. Hello everyone!! I come back on this topic because I was trying to use OpenApi to get some info on the devices managed by my KSC but I have problem calling login API. The error I get is 401 Unauthorized, that (reading the documentation available on the KSC) seems to be casued by a wrong formatted header. Here below I post my code (vb.net): WReq = CType(WebRequest.Create("https://" + ksc + ":13299/api/v1.0/login"), HttpWebRequest) ksc_u_b64 = System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(ksc_u)).ToString() ksc_p_b64 = System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(ksc_p)).ToString() ksc_h_b64 = System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(ksc_h)).ToString() WReq.Headers.Add("Authorization", "KSCBasic user=" + ksc_u_b64 + ", pass=" + ksc_p_b64) 'WReq.Headers.Add("X-KSC-VServer", ksc_h_b64) WReq.Method = "POST" WReq.ProtocolVersion = HttpVersion.Version11 WReq.ContentType = "application/json" 'WReq.ContentLength = 2 System.Net.ServicePointManager.Expect100Continue = False WReq.Timeout = 12000000 Dim jsonBytes = Encoding.UTF8.GetBytes("{}") WReq.ContentLength = jsonBytes.Length Using reqStream = WReq.GetRequestStream() reqStream.Write(jsonBytes, 0, jsonBytes.Length) End Using WResp = CType(WReq.GetResponse(), HttpWebResponse) ksc = ip_address of my KSC ksc_u_b64 = user base64 encoded (I am using a domain admin user, in order to be sure to have the permission ksc_p_b64 = password base64 encoded I have also tried passiong user and password with “”, as well I have also tried passing the parameter internal="1" (I have made a try with =”0” too) and tried also passing the parameter X-KSC-VServer (the variable ksc_h_b64 in my code) but with no luck :( Could you please help me out solving the problem? I have no idea where to turn my head. Thank you in advance Cheers Matteo
×
×
  • Create New...