Solved

Creating SSL Socket

Posted on 2001-06-18
7
891 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
convert char array to number in c 5 85
How and where to get Business Intelligence Development Studio? 2 87
Dynamically allocate memory 9 60
FMX TCameraComponent Problem 2 71
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…

832 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