自己署名入り証明書の場合は、以下のプログラムで。
[引用]
http://www.atmarkit.co.jp/fdotnet/dotnettips/867sslavoidverify/sslavoidverify.html
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using System.Net.Security;
using System.Windows.Forms;
using System.Security.Cryptography.X509Certificates;
namespace WCFTest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(OnRemoteCertificateValidationCallback);
}
private void button1_Click(object sender, EventArgs e)
{
var client = new ServiceReference1.Service1Client();
var s = client.GetData(10);
MessageBox.Show(s);
client.Close();
}
private bool OnRemoteCertificateValidationCallback(
Object sender,
X509Certificate certificate,
X509Chain chain,
SslPolicyErrors sslPolicyErrors)
{
return true; // 「SSL証明書の使用は問題なし」と示す
}
}
}
0 件のコメント:
コメントを投稿