Namedpipe和OpenSSL [英] Namedpipe and OpenSSL

查看:106
本文介绍了Namedpipe和OpenSSL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我开发了一个客户端和服务器,它使用OpenSSL通过TCP使用TLS进行通信,并且运行良好。



但我需要通过Namedpipe进行沟通,并且有一个问题:

当我创建一个namedpipe时,我打电话给:

Hello,

I developed a client and server that use the OpenSSL to communicate using TLS via TCP, and it is working very well.

But I need to communicate via Namedpipe, and there is the question:
When I create a namedpipe, I call:

HANDLE hPipe = CreateNamedPipe(...);
ConnectNamedPipe(hPipe, NULL);



连接Namedpipe后,我需要打电话:


After the Namedpipe is connected, I need call:

int SSL_set_fd(SSL *ssl, int fd);



正如我们所看到的,hPipe是一个HANDLE,但我需要将此HANDLE转换为int。所以我尝试使用下面的方法获得一个int然后调用SSL_set_fd(ssl,fd):


As we can see, the "hPipe" is a HANDLE, but I need convert this HANDLE to int. So I tried to use the below to get a "int" then call SSL_set_fd(ssl, fd):

int fd = _open_osfhandle(reinterpret_cast<intptr_t>(hPipe), 0); 



_open_osfhandle()的返回值为3,但当我尝试调用SSL_accept()时,OpenSSL不接受。



我做错了吗?

还有其他方法可以将OpenSSL与Namedpipe一起使用吗?

注意:我正在使用Microsoft Visual Studio,C ++。



谢谢。


The return of _open_osfhandle() will be "3", but OpenSSL isn't accepting when I try call "SSL_accept()".

Am I doing something wrong?
Is there other way to use OpenSSL with Namedpipe?
Note: I'm using the Microsoft Visual Studio, C++.

Thank you.

推荐答案

您正在尝试将HANDLE转换为FD 。

也许open_osf_handle不能正常工作。



尝试跳过这一步。

在Unix中命名管道直接用fopen打开

FILE * fpwrite = fopen(\\\\\\pipe \\SamplePipe,....) />


根据http://social.msdn.microsoft.com/Forums/vstudio/ EN-US / fc12d839- 3358-4eca-ba15-893e146a5e7b / is-it-it-open-named-pipes-on-windows-using-fopen-in-write-only?forum = vcgeneral [ ^ ]有人回答说它也应该可以在Windows中使用。



我从未见过有人在命名管道上运行SSL。

我不是100%肯定它会起作用,但当然值得一试。

祝你好运。
You are trying to convert a HANDLE into an FD.
Maybe open_osf_handle doesn't work as it should.

Try skipping that step.
In Unix named pipes are opened directly with fopen
FILE* fpwrite = fopen("\\\\.\\pipe\\SamplePipe", ....)

According to http://social.msdn.microsoft.com/Forums/vstudio/en-US/fc12d839-3358-4eca-ba15-893e146a5e7b/is-it-possible-to-open-named-pipes-on-windows-using-fopen-in-write-only?forum=vcgeneral[^] someone answered that it should be possible in Windows too.

I have never seen anyone run SSL over a named pipe.
I am not 100% sure it will work, but it is worth a try of course.
Good luck.


这篇关于Namedpipe和OpenSSL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆