Hello everybody,
I’m trying to run a http web server with ssl on my fez raptor. I’m using latest version of netmf (Microsoft .NET Micro Framework 4.3 (QFE2) & GHI Electronics NETMF SDK 2015 R1) I used openSSL certification according to :
this is the code i’m using:
localEndPoint = new IPEndPoint(IPAddress.Any, 2000);
server.Bind(localEndPoint);
server.Listen(1);
using (SslStream sslStream = new SslStream(server))
{
try
{
X509Certificate serverCert = new X509Certificate(Resources.GetBytes(Resources.BinaryResources.ca) , "myPassword");
sslStream.AuthenticateAsServer(serverCert,
SslVerification.NoVerification,
new SslProtocols[] { SslProtocols.Default });
sslStream.ReadTimeout = -1;
byte[] inBuffer = new byte[1000];
int count = sslStream.Read(inBuffer, 0, inBuffer.Length);
string message = new string(Encoding.UTF8.GetChars(inBuffer));
while (true)
{
Socket clientSocket = server.Accept();
new ProcessClientRequest(clientSocket);
}
}
catch (Exception e)
{
}
}
But when it reach the sslStream.AuthenticateAsServer, It goes to catch with following message:
Can anybody help? Is it related to te netmf sdk version?
Thanks
@ John - It is strange…!
We have 2 tools. MFDeploy and Fez Config
when I try to update ssl seed through FEZ Config => Deployment (Advance). nothing happened. No error and no feed back!
Is it normal?
But the same work using MFDeploy seems to be ok. MFDeploy => target => manage device keys => update ssl seed. it shows:
[quote]
I’m using latest version of netmf (Microsoft .NET Micro Framework 4.3 (QFE2) & GHI Electronics NETMF SDK 2015 R1) [/quote]
Latest is 2016 R1, should update to that one to get SSl working on your device.
After updated to latest firmware, remember to update SSL seed before starting.
Not quite Dat. The latest supported version is SDK 2015 R1, the latest PRE-RELEASE (beta) is 2016 R1. Since there are SSL updates in the beta, what we should be suggesting is that @ Ehsan Ansari should TEST the beta 2016 R1 and see if that addresses the issue they’re seeing, so that once the full release of 2016 R1 occurs they will know the fix needed is present. (Gus continues to say that the beta is a test SDK and not to use it in production; we don’t know what the poster is doing and whether using the beta will be a problem for them or not)
OK guys…
I updated it to 2016 - pre-release R1. But nothing changed. The same error occurs… :wall:
(I updated the ssl seed using MFDeploy after updating to 2016 - pre-release R1)
@ Ehsan Ansari - Under project properties you will change the device transport from USB to Emulator. You will need to take out all GHI specific functions like the ENC28. It will use the network interface on your computer instead. The rest of your code will remain the same.
@ John - I can’t execute your scenario
As a test, I created a new gadgeteer project and put just one Fez Raptor mainboard in program.gadgeteer diagram. After that I changed deployment transport from usb to emulator. But, this is the error I recieve:
So what is wrong?
the body of program.cs contains only :
For Emulator:
If I remember correctly, there should be an example of this when we installed NetMF.
it is usually under C:\Users\xxx\Documents\Microsoft .NET Micro Framework 4.3\Samples\HttpClient. Don’t change their configuration then it will run on Emulator.
For real device:
Try you code with google first, make sure it work then switch to the host you wanted. Of course, change the certificate if needed.
@ John - Ok…Finally I tested my code on pure netmf project running on emulator.
(my problem was solved by writing : SslStream sslStream = new SslStream(serverSocket.Accept()) !!!)
Anyway, The main problem still exists. on the line :
@ andre.m - There was a problem about running same code in emulator which is solved right now.
But still I cannot use self sign pem certificate to run my own http web server. Following line makes error: