当前位置:网站首页>OpenSSL的SSL/BIO_get_fd
OpenSSL的SSL/BIO_get_fd
2022-07-03 17:47:00 【星哥玩雲】
只要是用到了OpenSSL,總會碰到讓人心塞的事。 這次是SSL_get_fd。我用一種很簡單的方式創建了一個SSL對象,直接在這個對象上進行SSL的accept:
bio = BIO_new(BIO_s_accept()); BIO_set_accept_port(bio, "1234"); BIO_do_accept(bio); SSL_set_bio(ssl, bio, bio); SSL_accept(ssl);
這樣就不必折騰討厭的sockaddr了。後來我想在和這個SSL對象關聯的底層socket上執行setsockopt,想當然的使用了SSL_get_fd/BIO_get_fd這個非常自明的API。到此為止非常棒。接下來就不爽了,我發現setsockiot最終操作的那個描述符是listnen套接字,而不是accept返回的那個套接字。這似乎在API層面上十分合理,畢竟bio的參數就是一個BIO_s_accept,而和它關聯的就是一個listen套接字。想要正確的得到accept返回的讀寫socket描述符,你得這麼寫:
[plain] view plaincopyprint?在CODE上查看代碼片派生到我的代碼片
BIO_get_fd(BIO_next(bio), &sd);
BIO_get_fd(BIO_next(bio), &sd);問題是,你必須知道這個BIO stack是如何排列的才能寫出上面的代碼,做到如此最好的辦法就是看OpenSSL的源代碼。
BIO的API設計就一定要設計成get/set_fd嗎?BIO就一定要和一個fd相關嗎?memory類型的BIO如果get fd的話,會返回怎麼的錯誤嗎呢?既然BIO構成了一個疊加的IO stack,那麼也許之有最下面的那個才會和一個UNIX fd相關聯,那為何不直接返回最下面那個呢?
边栏推荐
- Leetcode Valentine's Day Special - looking for a single dog
- ArrayList analysis 3: delete elements
- Applet with multiple tabs and Swipers + paging of each tab
- Leetcode 669 pruning binary search tree -- recursive method and iterative method
- Five problems of database operation in commodity supermarket system
- First day of rhcsa study
- Records of long objects and long judgments in the stream of list
- VM11289 WAService. js:2 Do not have __ e handler in component:
- [combinatorics] recursive equation (solution of linear non-homogeneous recursive equation with constant coefficients | standard form and general solution of recursive equation | proof of general solut
- When absolutely positioned, the element is horizontally and vertically centered
猜你喜欢
基于人脸识别的课堂考勤系统 tkinter+openpyxl+face_recognition
Wechat applet for the first time
Hongmeng fourth training
Leetcode 108 converts an ordered array into a binary search tree -- recursive method
Records of long objects and long judgments in the stream of list
Research Report on competitive strategy Outlook Analysis and investment strategic planning of China's smart home equipment industry, 2022-2028
Global and Chinese pediatric palliative care drug market development research and investment planning recommendations report 2022-2028
Vs2013 has blocked the installer, and ie10 needs to be installed
【JokerのZYNQ7020】DDS_ Compiler。
1147_ Makefile learning_ Target files and dependent files in makefile
随机推荐
WEB-UI自动化测试-最全元素定位方法
Research on Swift
Kotlin的协程:上下文
[UE4] brush Arctic pack high quality Arctic terrain pack
List的stream中Long对象与long判等问题记录
问题随记 —— 在 edge 上看视频会绿屏
毕业总结
PS screen printing brush 131, many illustrators have followed suit
鸿蒙第三次培训
Web-ui automated testing - the most complete element positioning method
聊聊支付流程的設計與實現邏輯
1164 Good in C
ArrayList analysis 3: delete elements
Classroom attendance system based on face recognition tkinter+openpyxl+face_ recognition
Enterprise custom form engine solution (XI) -- form rule engine 1
Write a program to process a list container of string type. Find a special value in the container 9.27: and delete it if found. Rewrite the above procedure with deque container.
Is AI too slow to design pictures and draw illustrations? 3 sets of practical brushes to save you
Servlet specification Part II
[RT thread] NXP rt10xx device driver framework -- pin construction and use
[combinatorics] generating function (shift property)