Solved

Creating SSL Socket

Posted on 2001-06-18
7
888 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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
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…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

706 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now