Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #300 from luvit/test-tls-client-econnreset
Test tls client econnreset
- Loading branch information
Showing
4 changed files
with
85 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
require('helper') | ||
local fixture = require('./fixture-tls') | ||
local childprocess = require('childprocess') | ||
local os = require('os') | ||
local tls = require('tls') | ||
local timer = require('timer') | ||
|
||
local args = { | ||
's_server', | ||
'-accept', fixture.commonPort, | ||
'-key', 'fixtures/keys/agent1-key.pem', | ||
'-cert', 'fixtures/keys/agent1-cert.pem', | ||
} | ||
|
||
local child = childprocess.spawn('openssl', args) | ||
child:on('error', function(err) | ||
p(err) | ||
end) | ||
child:on('exit', function(exit_status) | ||
print('server exited') | ||
end) | ||
child:on('error', function(err) | ||
p(err) | ||
end) | ||
child.stdout:on('data', function(data) | ||
print('server: ' .. data) | ||
end) | ||
child.stderr:on('data', function(data) | ||
print('server: ' .. data) | ||
end) | ||
|
||
interval = timer.setInterval(100, function() | ||
local success, err = pcall(child.stdin.write, child.stdin, "Hello world") | ||
end) | ||
|
||
timer.setTimeout(200,function () | ||
local c | ||
c = tls.connect({port = fixture.commonPort, host = '127.0.0.1'}) | ||
c:on('error', function(err) | ||
print("got connection error") | ||
p(err) | ||
end) | ||
c:on('closed', function() | ||
print('got closed signal') | ||
end) | ||
c:on('data', function(data) | ||
print('client got: ' .. data) | ||
end) | ||
c:on('end', function() | ||
c:destroy() | ||
end) | ||
end) | ||
|
||
timer.setTimeout(1000, function() | ||
child:kill(9) | ||
end) | ||
|
||
timer.setTimeout(1010, function() | ||
process.exit(0) | ||
end) | ||
|
||
process:on('error', function(err) | ||
assert(false) | ||
p(err) | ||
end) |