Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TLS certs support for mutual authentication #83

Merged
merged 8 commits into from
Oct 15, 2022

Conversation

zhiburt
Copy link
Contributor

@zhiburt zhiburt commented Oct 5, 2022

Hi there

Thanks for the good first issue label

Let me know if I did something wrong (which I could 😞).

closes #82

Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
@codecov
Copy link

codecov bot commented Oct 6, 2022

Codecov Report

Merging #83 (8f37147) into master (eddadbb) will increase coverage by 1.62%.
The diff coverage is 69.23%.

@@            Coverage Diff             @@
##           master      #83      +/-   ##
==========================================
+ Coverage   82.18%   83.81%   +1.62%     
==========================================
  Files          18       18              
  Lines        1600     1637      +37     
==========================================
+ Hits         1315     1372      +57     
+ Misses        241      213      -28     
- Partials       44       52       +8     
Impacted Files Coverage Δ
core/types/scenario.go 84.00% <43.75%> (-10.92%) ⬇️
config/json.go 74.43% <75.00%> (-0.27%) ⬇️
main.go 55.30% <78.94%> (-0.77%) ⬇️
core/scenario/requester/http.go 82.99% <100.00%> (+9.47%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Member

@kursataktas kursataktas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this fantastic work 🎊 🚀

I left a few comments. Please take a look at them.

Also, you may consider adding some test cases on json_test.go and main_test.go

config/json.go Outdated Show resolved Hide resolved
core/types/scenario.go Outdated Show resolved Hide resolved
core/types/scenario.go Outdated Show resolved Hide resolved
core/types/scenario.go Outdated Show resolved Hide resolved
core/scenario/requester/http.go Outdated Show resolved Hide resolved
core/engine_test.go Outdated Show resolved Hide resolved
Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
@zhiburt
Copy link
Contributor Author

zhiburt commented Oct 6, 2022

Also, you may consider adding some test cases on json_test.go and main_test.go

done

main_test.go Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
@kursataktas
Copy link
Member

TODO: Readme update

Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
@kursataktas
Copy link
Member

Everything looks clear @zhiburt 🚀

There are 2 things left before merging this branch:

  1. Could you please update the related section of the Readme
  2. Could you please update the description of this PR with the explanation of your manual test steps? It would be useful for future bug investigations.

Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
@zhiburt
Copy link
Contributor Author

zhiburt commented Oct 10, 2022

Could you please update the related section of the Readme

Added

Could you please update the description of this PR with the explanation of your manual test steps? It would be useful for future bug investigations.

I don't have any manual steps :)
I've added an descriptions for the tests in engine_test.go.

To test it manually you would need to spawn a webserver with chosen certs and direct ddosify to the webserver.

@zhiburt
Copy link
Contributor Author

zhiburt commented Oct 10, 2022

I've played a little bit and it works. (Took me a while...)
Based on https://medium.com/@sevcsik/authentication-using-https-client-certificates-3c9d270e8326

  1. Generate certificates following the guide.
  2. Run this server node your_file.js
const https = require('https')
const fs = require('fs');

let server = https.createServer({
    requestCert: true,
    rejectUnauthorized: false,
    key: fs.readFileSync('server_key.pem'),
    cert: fs.readFileSync('server_cert.pem'),
    ca: [ fs.readFileSync('server_cert.pem') ]
},
(req, res)  => {
    const cert = req.connection.getPeerCertificate()
    if (cert != null && cert.subject != null) {
        console.info(`Hello ${cert.subject.CN}, your certificate was issued by ${cert.issuer.CN}!`)
    }

    if (!req.client.authorized) {
        res.writeHead(401);
        return res.end('Invalid client certificate authentication.');
      }

      console.info("123213321");

      res.writeHead(200);
      res.end('Hello, world!');
});

server.listen(8098)
  1. Run ddosify without certs
go run main.go -t https://127.0.0.1:8098

image

  1. Run ddosify with alice certs
go run main.go -t https://127.0.0.1:8098 --cert_path=/alice_cert.pem --cert_key_path=/alice_key.pem

image

@kursataktas
Copy link
Member

kursataktas commented Oct 11, 2022

Fascinating work @zhiburt 🎊 Thank you very much for your effort. I'll merge the PR this week.

@kursataktas kursataktas merged commit e53cd98 into getanteon:master Oct 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Is there support for mutual tls authentication?
2 participants