Solved

Creating SSL Socket

Posted on 2001-06-18
7
893 Views
Last Modified: 2013-12-14
Dear Friends,

    I would like to know if it is possible to create a SSL connection oriented Socket using Visual Basic 6.0 or Visual C++ 6.0, I think it can be done using SChannel but till now i could'nt find any samples on that though i found one for HTTPS protocol.

   Any solution with a sample would be greatly appreciated.

   Thanking you in advance

Arvind
0
Comment
Question by:Arvindtn
7 Comments
 
LVL 30

Expert Comment

by:Axter
ID: 6201809
Do you want to create an MFC project?
0
 
LVL 30

Expert Comment

by:Axter
ID: 6201825
In reading MSN, this doesn't seem to be something that you would to via C++/VB.

The following info comes from MSN docs:
Securing HTTP Transmissions (SSL)
SSL (Secure Sockets Layer) is a protocol that is used to protect HTTP transmissions from unwanted eavesdropping. Visual InterDev supports the optional use of SSL over the client/server link at design time and when performing a Web Copy operation. You can also use SSL during run time. You choose to use an SSL connection when you create a new Web project or initiate a Web Copy operation.

When an SSL connection is in use, all HTTP requests and replies are encrypted before transmission and decrypted after receipt. This process does require additional time and slows performance.

Except for this encryption/decryption step, all Visual InterDev operations take place exactly as they would over a non-SSL connection. You must obtain and install an SSL certificate on your Web server before you can initiate an SSL connection. For more information on obtaining and installing an SSL certificate on an Internet Information Server, see Securing Your Site Against Intruders in the Internet Information Server documentation.

0
 
LVL 4

Expert Comment

by:AssafLavie
ID: 6202084
It's quite possible, I've done it a while back. MSDN has an example (or actually, the platform SDK does...).
You should be aware though that SChannel isn't easy to use (SSPI in general is hard) and it may be just a lot simpler to use WinInet.
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 15

Expert Comment

by:Tommy Hui
ID: 6203132
Yes, it is possible. Here's sample code in C++ using WinInet:

#include <windows.h>
#include <tchar.h>
#include <wininet.h>
#include <stdio.h>
#include <string>

#import "msxml.dll"
using namespace MSXML;

using namespace std;

#pragma comment(lib, "wininet.lib")

TComInitialize g_ComInit;

int _tmain(int argc, _TCHAR* argv[], _TCHAR* envp[])
{
     if (argc < 1)
     {
          _tprintf(_T("Failed to find arguments.\n"));
          return -1;
     }

     HINTERNET hSession = InternetOpen(_T("HttpGet"),
          INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);

     if (hSession)
     {
          bool isSsl = false;

          for (int i = 1; i < argc; i++)
          {
               if (strcmpi(argv[i], "-s") == 0)
               {
                    isSsl = true;
                    continue;
               }

               HINTERNET hFile = InternetOpenUrl(hSession, argv[i], NULL, 0,
                                                         isSsl ? INTERNET_FLAG_SECURE : 0, 0);
               if (hFile)
               {
                    DWORD bytesAvailable = 0;
                    if (InternetQueryDataAvailable(hFile, &bytesAvailable, 0, 0))
                    {
                         _tprintf(_T("Bytes available: %d\n"), bytesAvailable);
                    }

                    const int BUFFLEN = 1024;
                    TCHAR buffer[BUFFLEN];
                    DWORD dwRead;
                    string result;

                    while (InternetReadFile(hFile, buffer, BUFFLEN - sizeof(TCHAR), &dwRead))
                    {
                         if (dwRead == 0)
                              break;

                         buffer[dwRead / sizeof(TCHAR)] = _T('\0');
                         result += buffer;
                    }

                    InternetCloseHandle(hFile);
                   
                    _tprintf(_T("%s\n"), argv[i]);
                    _tprintf(_T("%s\n"), result.c_str());
               }
          }

          InternetCloseHandle(hSession);
     }
     return 0;
}

Run the program with -s to use secure or not.

For example,

  httpget http://www.microsoft.com

to see Microsoft's web page. Or

  httpget -s {path starting with https://)

to retrieve the secured web page.
0
 

Author Comment

by:Arvindtn
ID: 6205549
 I want to have it as a COM component not as a MFC Project

  Iam using a TCP socket and iam not using the HTTP protocol. I think SSL in SCHannel is supported only in Windows 2000 and Windows NT.

  This what i have done so far, i have created a Socket in Visual Basic and i take full advantage of the event model it gives me. when i want to do some processing on the message i receive from the client socket, i pass the message with the Socket handle to Visual C++ which in turn process the message in a thread and sends the processed message back to the client through the socket handle in Visual C++. Now the problem is in having a SSL

  I think i have found the solution.
i have found a site which provides me an Activex dll which enables me to have a SSL over a Socket. Check this Site out www.nsoftware.com iam yet to test it and see if it is working for me.

  I would really like to write the establishing SSL over TCP Socket on my own as part of my self development and i like to use the existing code for my project.

   So kindly send me if it is ok to use the activex, for which i have provided the link above or to implement it through SChannel.

Thank you in Advance
Arvind
0
 
LVL 11

Expert Comment

by:griessh
ID: 6819213
I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. Unless there is objection or further activity,  I will suggest to refund the points and PAQ at zero points.

The link to the Community Support area is: http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
0
 

Accepted Solution

by:
ComTech earned 0 total points
ID: 6837630
This dormant question will be placed in PAQ.


Regards,
ComTech
CS @ EE
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
FMX enumerated colours 2 115
How to copy an image file into clipboard C/C++? 1 199
FMX TCameraComponent Problem 2 84
What is sub-make ? 2 71
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question