Cannot establish SSL connection

May 31, 2010 at 6:11 PM
Edited May 31, 2010 at 6:13 PM
Hi,
I've been trying to use this library with ssl connections without success.
I've even tried to create certiticates using openssl.exe and makecert.exe but none of them seem to work.

This is the code I'm using :

#######################################################################################
Imports HttpServer.HttpListener
Imports System.Security.Cryptography.X509Certificates
Imports System.Net.Security
'Imports System.Net

Public Class Form1
Public Sub OnRequest(ByVal sender As Object, ByVal e As HttpServer.RequestEventArgs)

e.Response.Connection.Type = HttpServer.Headers.ConnectionType.Close
Dim buff() = System.Text.Encoding.UTF8.GetBytes("<html><body>hello world !</body></html>")
e.Response.Body.Write(buff, 0, buff.Length)

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim cert As New Security.Cryptography.X509Certificates.X509Certificate2("C:\OpenSSL\server.cer", "")
Dim listen As HttpServer.HttpListener
listen = HttpServer.HttpListener.Create(System.Net.IPAddress.Any, 32000, cert)
listen.Start(5)
AddHandler listen.RequestReceived, AddressOf OnRequest
System.Threading.Thread.Sleep(9999999)


End Sub
End Class
#############################################################################################

Everytime I try to connect using firefox/ie I can see this error in Immediate Window:

A first chance exception of type 'System.ArgumentException' occurred in System.dll
A first chance exception of type 'System.ArgumentException' occurred in System.dll
A first chance exception of type 'System.ArgumentException' occurred in System.dll
A first chance exception of type 'System.ArgumentException' occurred in System.dll


What am I doing wrong ?

Thanks !
Coordinator
Jun 22, 2010 at 5:07 AM

Send me your certificate. Hart to tell what's going wrong by looking at that code.