UNI.T Naver Clova face recognition link.

Asked 2 years ago, Updated 2 years ago, 95 views

Hi, everyone. I would like to link Naver API to UNI.T.T. First of all, it works well on C# When UNI.T spins it TlsException: Invalid certificate received from server. Error code: 0xffffffff80092012 Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate.validateCertificates (Mono.Security.X509.X509CertificateCollection certificates) An error message appears.

How do I resolve this error? Below is the Developer's Guide https://developers.naver.com/docs/clova/api/#/CFR/API_Guide.md#Java Is there anyone who needs to solve this problem?

using System; using System.Net; using System.Text; using System.IO; using System.Collections.Generic; using System.Collections.Specialized;

namespace NaverAPI_Guide { public class APIExamFace { static void Main(string[] args) { string boundary = "----------------------------" + DateTime.Now.Ticks.ToString("x"); string FilePath = "YOUR_FILE_NAME"; FileStream fs = new FileStream(FilePath, FileMode.Open, FileAccess.Read); byte[] fileData = new byte[fs.Length]; fs.Read(fileData, 0, fileData.Length); fs.Close();

        string CRLF = "\r\n";
        string postData = "--" + boundary + CRLF + "Content-Disposition: form-data; name=\"image\"; filename=\"";
        postData += Path.GetFileName(FilePath) + "\"" + CRLF +"Content-Type: image/jpeg" + CRLF + CRLF;
        string footer = CRLF + "--" + boundary + "--" + CRLF;

        Stream DataStream = new MemoryStream();
        DataStream.Write(Encoding.UTF8.GetBytes(postData), 0, Encoding.UTF8.GetByteCount(postData));
        DataStream.Write(fileData, 0, fileData.Length);
        DataStream.Write(Encoding.UTF8.GetBytes("\r\n"), 0, 2);
        DataStream.Write(Encoding.UTF8.GetBytes(footer), 0, Encoding.UTF8.GetByteCount(footer));
        DataStream.Position = 0;
        byte[] formData = new byte[DataStream.Length];
        DataStream.Read(formData, 0, formData.Length);
        DataStream.Close();

        string url = "https://openapi.naver.com/v1/vision/celebrity"; // Recognize celebrity faces
        //string url = "https://openapi.naver.com/v1/vision/face"; // Face detection
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
        request.Headers.Add("X-Naver-Client-Id", "YOUR_CLIENT_ID");
        request.Headers.Add("X-Naver-Client-Secret", "YOUR_CLIENT_SECRET");
        request.Method = "POST";
        request.ContentType = "multipart/form-data; boundary=" + boundary;
        request.ContentLength = formData.Length;
        using (Stream requestStream = request.GetRequestStream())
        {
            requestStream.Write(formData, 0, formData.Length);
            requestStream.Close();
        }
        HttpWebResponse response = (HttpWebResponse)request.GetResponse();
        Stream stream = response.GetResponseStream();
        StreamReader reader = new StreamReader(stream, Encoding.UTF8);
        string text = reader.ReadToEnd();
        stream.Close();
        response.Close();
        reader.Close();
        Console.WriteLine(text);
    }
}

}

unity c#

2022-09-22 18:45

1 Answers

ssl error.

There seems to be something wrong with the certificate received from the server.

First of all, please remove s from the access address https://~~ and test it with http://~.


2022-09-22 18:45

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.