[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Creating SSL Socket

Posted on 2001-06-18
7
Medium Priority
?
898 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
The viewer will learn how to synchronize PHP projects with a remote server 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…
Suggested Courses

650 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