473,385 Members | 1,922 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

HTTPS on Compact Framework

As a new member, I hope I am posting correctly. Bear with me if not !

I found a posting by Earle Oxner that very closely matches the situation we are in. Sadly, there were no replies to his post, so I am asking a similar question. We have developed a .Net Compact Framework 2 forms application & deployed it on a 2 PDAs, one running Windows Mobile 2003 2nd Edition and one running Windows Mobile v5.

The app's purpose is to POST data to an HTTPS url and the code is below
Expand|Select|Wrap|Line Numbers
  1. Public Shared Function Send(ByVal URL As String, _
  2.         Optional ByVal PostData As String = "", _
  3.         Optional ByVal Method As HTTPMethod = HTTPMethod.HTTP_GET, _
  4.         Optional ByVal ContentType As String = "")
  5.  
  6.         Dim Request As HttpWebRequest = WebRequest.Create(URL) ' opens a connection to the URL 
  7.         Dim Response As HttpWebResponse
  8.         Dim SW As StreamWriter
  9.         Dim SR As StreamReader
  10.         Dim ResponseData As String
  11.         Dim flag As Boolean
  12.         ' Prepare Request Object
  13.         Request.Method = Method.ToString().Substring(5) 'find out if it's a POST or GET.  
  14.  
  15.         ' Set form/post content-type if necessary
  16.         If (Method = HTTPMethod.HTTP_POST AndAlso PostData <> "" AndAlso ContentType = "") Then
  17.             ContentType = "application/x-www-form-urlencoded"
  18.         End If
  19.  
  20.         ' Set Content-Type
  21.         If (ContentType <> "") Then
  22.             Request.ContentType = ContentType
  23.             Request.ContentLength = PostData.Length
  24.         End If
  25.  
  26.         flag = False 'set to false, if we instantiate SW then it will be set to true so that the Finally knows whether to kill it or not.
  27.         ' Send Request, If Request
  28.         If (Method = HTTPMethod.HTTP_POST) Then
  29.             Try
  30.                 SW = New StreamWriter(Request.GetRequestStream()) 'new stream writer to the open connection. 
  31.                 flag = True
  32.                 SW.Write(PostData) 'write the data to the open connection.
  33.             Catch Ex As Exception
  34.                 'handle any errors here; return a string to say it failed.
  35.                 'Throw Ex'this was the default action that caused a crash.
  36.                 Return "Failure to send"
  37.                 Exit Function
  38.             Finally
  39.                 If flag Then
  40.                     SW.Close()
  41.                 End If
  42.             End Try
  43.         End If
  44.  
  45.         ' Receive Response
  46.         flag = False 'reset the flag for the next block
  47.         Try
  48.             Response = Request.GetResponse
  49.             SR = New StreamReader(Response.GetResponseStream())
  50.             flag = True
  51.             ResponseData = SR.ReadToEnd()
  52.         Catch Wex As System.Net.WebException
  53.             SR = New StreamReader(Wex.Response.GetResponseStream())
  54.             ResponseData = SR.ReadToEnd()
  55.             Throw New Exception(ResponseData)
  56.         Finally
  57.             If flag Then
  58.                 SR.Close()
  59.             End If
  60.         End Try
  61.  
  62.         'we now have a response from the server, probably a positive one.
  63.         ' need to find the phrase 'Message received successfully'
  64.         Dim result As Integer = InStr(ResponseData, "Message received successfully", CompareMethod.Text)
  65.         'MsgBox(result)
  66.         If result <> 0 Then
  67.             'it was successfull.
  68.             Return "Success"
  69.         Else
  70.             Return "Failure"
  71.         End If
  72.  
  73.         Return ResponseData
  74.     End Function 
When the URL parameter is a valid http: address, the code works fine. When it is a https: address, it fails at the line
SW = New StreamWriter(Request.GetRequestStream())

We tried installing a Certificate on the PDA and offering it by addressing the same https url through Internet Explorer before then running the application. We hoped this would allow the app to use the previously-certificated connection, but it failed as before.

Next we thought about certificating in code within the app and found a posting on Jan Tielens' Blog site suggesting this was possible. However, it turned out that the ICertificatePolicy interface could not be accessed in an app using the Compact Framework (which ours is)

Now we are stuck ! Any help on using the Compact Framework version of VB.Net to programatically broker an HTTPS connection would be greatly appreciated
Jan 5 '07 #1
2 1548
radcaesar
759 Expert 512MB
Along with enabling SSL on the Windows Mobile 2003 for Smartphone agent, you will also need to enable SSL on the Device Manager server.

Have u done with that ?

:)
Jan 5 '07 #2
Along with enabling SSL on the Windows Mobile 2003 for Smartphone agent, you will also need to enable SSL on the Device Manager server.

Have u done with that ?

:)
Hello radcaesar,

Although we could not find any setting on the PDA's o/s that related to enabling SSL, we can make an https connection on the device when we use Internet Explorer browser, so I assume SSL is enabled and correctly configured on the server (actually an iChain server) and the PDA device itself. Problems arise when trying to make the connection using the VB.Net app rather than the browser.
Jan 22 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: boble | last post by:
Sorry, it's may be off topic ;_((( The following article http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnppc2k3/ht ml/winmob03.asp states that a.. Microsoft Windows .NET...
0
by: Earle Oxner | last post by:
We are developing an application on PocketPC2002 platform and we are trying to make webservice calls using HTTPS. HTTP works fine but HTTPS does not work. The same code which doesn't work on...
2
by: Duncan | last post by:
I am using the evaluation version of CE.NET 4.1. I had also installed the release version of the Compact Framework. I uninstalled the CE.NET 4.1, and then realized I needed it again and...
1
by: Asad Khan | last post by:
Hi, I have Visual Studio 2002 Enterprise Architecture Edition. I was wondering if anyone has any information on how I can develop applications for .Net Compact Framework using this IDE. I've heard...
2
by: Hans Kesting | last post by:
Is it possible to mix code meant for the CompactFramework and code meant for the standard framework? We are trying to make PDA and light-weight "laptop" versions of one application. This means a...
2
by: MarkAurit | last post by:
I have a web service Im using on a machine via http in a dmz that works file. Im now attempting to use it in a second server, this one using https. When I attempt to add the Web Reference in vs.net...
4
by: Jason P | last post by:
Basically we have a web method with a dynamic URL. The client is developed in C++ and I've been using the webReference.SetUrl( "http://test.example.com..." ) method successfully with various web...
5
by: bob | last post by:
Hi Using 2003 - targeting the compact framework (c#), but would like to do most development using the full.net (manually leaving out stuff not in the compact framework). Q. Trying to find a...
3
by: m2abhi25 | last post by:
Hi All, I am trying to send an https:// request from my .Net CF application. The code is as follows : try { HttpWebRequest request = ( HttpWebRequest ) ...
3
by: Greg | last post by:
Hello all, I am looking to download an image from a website from within a compact framework pda app. I have tried everything I could find and thus I turn to you. Any help or suggestions would be...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.