login about faq

Hello,

I have to get data from a webservice (described as "like REST") , the site needs a certificate. We send some data in XML form but as contenttype text/plain (dont ask:-) ) and receive some data in XML form.

We have different certificates on the pc, so the one to be used comes from a file (see down)

In the next lines there is code from our working c# solution. But now need to do implement it in another project in VFP and want to use chilkat for it (which we use for ftp,..)

Can you give me a hint where to start or some code ?

Thanks a lot in advance tom

Here is the main part of the c# program :

namespace WebClientService

{ public class WebClient

{
    private readonly ILog _log;
    public WebClient()

    public string SendData(string uri, String xmlData)
    {

        var url = new Uri(uri);
        SecureWebClient client = new SecureWebClient();

       var response =client.UploadString(url, xmlData);

       _log.Debug(response);

        return response.ToString();

    }

    class SecureWebClient : System.Net.WebClient
    {

        protected override WebRequest GetWebRequest(Uri address)
        {
            HttpWebRequest request = (HttpWebRequest)base.GetWebRequest(address);

            ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
            //ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
            X509Certificate myCert =  X509Certificate2.CreateFromCertFile("ClientCertificate.cer");
            request.ClientCertificates.Add(myCert);
            return request;
        }
    }

}

}

asked Mar 21 at 06:58

tomkn's gravatar image

tomkn
1


Hi Tom,

You could start with this example "https://www.example-code.com/foxpro/http_public_key_pinning.asp", where you make a secure connection with server getting public key.

In your case you could use this "https://www.chilkatsoft.com/refdoc/xPublicKeyRef.html" to get public key from your certificate and use in the example above.

Once connected you could use "https://www.example-code.com/foxpro/rest_simple.asp" to use REST.

Hope this could help you as start.

Marcos

link

answered May 17 at 17:55

Sibuya's gravatar image

Sibuya
11

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×5
×4

Asked: Mar 21 at 06:58

Seen: 411 times

Last updated: May 17 at 17:55

powered by OSQA