⚲
Project
General
Profile
Sign in
Register
Home
Projects
Help
Search
:
Backport193
All Projects
Ruby
»
Backport193
Overview
Activity
Issues
Like
Download (892 Bytes)
Backport #5233
» openssl_write_failure.rb
A sample script showing the problem -
niklasb (Niklas Baumstark)
, 08/26/2011 08:45 PM
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require
'socket'
require
'openssl'
# set up SSL server
server
=
TCPServer
.
new
(
"127.0.0.1"
,
4433
)
key
=
OpenSSL
::
PKey
::
RSA
.
new
(
File
.
read
(
"server.pem"
))
cert
=
OpenSSL
::
X509
::
Certificate
.
new
(
File
.
read
(
"server.pem"
))
ssl_ctx
=
OpenSSL
::
SSL
::
SSLContext
.
new
ssl_ctx
.
key
=
key
ssl_ctx
.
cert
=
cert
server
=
OpenSSL
::
SSL
::
SSLServer
.
new
(
server
,
ssl_ctx
)
Thread
.
start
(
server
)
do
|
server
|
server
.
listen
(
1
)
conn
=
server
.
accept
str
=
"ä"
*
100000
# uncomment the following line as a workaround
#str.force_encoding "ascii"
conn
.
write
(
str
)
conn
.
close
end
socket
=
TCPSocket
.
new
(
"127.0.0.1"
,
4433
)
ssl_ctx
=
OpenSSL
::
SSL
::
SSLContext
.
new
ssl_socket
=
OpenSSL
::
SSL
::
SSLSocket
.
new
(
socket
,
ssl_ctx
)
ssl_socket
.
sync_close
=
true
ssl_socket
.
connect
str
=
ssl_socket
.
read
str
.
force_encoding
"utf-8"
puts
"str.size is %i (expecting 100000)"
%
str
.
size
« Previous
1
2
Next »
(1-1/2)
Loading...