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

ssl client certs #63

Closed
ghost opened this issue Sep 8, 2014 · 47 comments
Closed

ssl client certs #63

ghost opened this issue Sep 8, 2014 · 47 comments

Comments

@ghost
Copy link

ghost commented Sep 8, 2014

I wondered if you'd ever thought of supporting ssl client certs?

@tsenart
Copy link
Owner

tsenart commented Sep 8, 2014

What is the exact use case?

@ghost
Copy link
Author

ghost commented Sep 8, 2014

At the BBC we have a number of web services using SSL encryption (HTTPS) which the client can only communicate through with an SSL cert. JMeter and Tsung support such certification, but I am looking for a tool where I can write tests as code (not XML). I don't know enough about Go to add it in myself, but I intend to learn Go as I eventually want to contribute to an OS load-test tool.

@tsenart
Copy link
Owner

tsenart commented Sep 8, 2014

This functionality can be added relatively easily. I'll try to find the time to do it soon.

@ghost
Copy link
Author

ghost commented Sep 8, 2014

Many Thanks.

@tsenart tsenart closed this as completed in 370ee61 Sep 9, 2014
@tsenart
Copy link
Owner

tsenart commented Sep 9, 2014

@AidyLewis: Please download the latest release and let me know if it solves your problem.

@ghost
Copy link
Author

ghost commented Sep 9, 2014

Tested an endpoint without cert and I received a handshake failure in the results.
Tried a P12 which gave a bad cert.
converted p12 => pem with this command
$ openssl pkcs12 -nodes -in cert.p12 -out cert.pem
Again, I received a handshake failure.

using:
$ vegeta attack -duration=10s -rate=10 -targets=targets.txt -output=results.bin -cert=dev-cert.pem

I will try another .pem.

@AidyLewis

@tsenart
Copy link
Owner

tsenart commented Sep 9, 2014

Please include the inputs and outputs of your test runs. I suggest you run it as such:

echo "GET https://$HOSTNAME:$PORT" | vegeta attack -cert="$CERT" -duration=1s -rate=10 | tee results.bin | vegeta report

@ghost
Copy link
Author

ghost commented Sep 9, 2014

Hi,

I've attempted every conceivable way of converting a p12 to pem.

echo "GET https://api.stage.bbc.co.uk/locator/locations?order=importance&s=NW9%207NT&a=true" | vegeta attack -cert="dev-cert.pem" -duration=1s -rate=10 | tee results.bin | vegeta report
2014/09/09 17:30:56 Vegeta is attacking 1 targets in random order for 1s...
2014/09/09 17:30:57 Done! Writing results to 'stdout'...
Requests [total] 10
Duration [total] 899.647219ms
Latencies [mean, 50, 95, 99, max] 107.159577ms, 20.537454ms, 280.954271ms, 280.954271ms, 382.503234ms
Bytes In [total, mean] 0, 0.00
Bytes Out [total, mean] 0, 0.00
Success [ratio] 0.00%
Status Codes [code:count] 0:10
Error Set:
Get https://api.stage.bbc.co.uk/locator/locations?order=importance&s=NW9%207NT&a=true: remote error: handshake failure

@tsenart
Copy link
Owner

tsenart commented Sep 9, 2014

I am no expert in openssl but have you converted the certificate with the following?
openssl pkcs12 -in cert.p12 -passin pass:password -out cert.pem

I presume you are able to connect to your server with openssl directly. Is that the case?

@ghost
Copy link
Author

ghost commented Sep 15, 2014

I have not forgotten about this, I'll re-attempt it again this afternoon.

@ghost
Copy link
Author

ghost commented Sep 15, 2014

Hi,

I have managed to curl on the dev svn repo which uses ssl

curl --cert dev-cert.pem --cacert ca.pem https://repo.dev.bbc.co.uk/load-test-team/cloud-load-test/trunk/bake-scripts/set-up

But still unable to use the vegeta cert switch:

echo "GET https://repo.dev.bbc.co.uk/load-test-team/cloud-load-test/trunk/bake-scripts/set-up" | vegeta attack -cert="dev-cert.pem" -duration=1s -rate=10 | tee results.bin | vegeta report

....
Error Set:
Get https://repo.dev.bbc.co.uk/load-test-team/cloud-load-test/trunk/bake-scripts/set-up: remote error: handshake failure

Many Thanks

Aidy

@tsenart
Copy link
Owner

tsenart commented Sep 17, 2014

Historically, there have been a number of issues with SSL code in the Go standard library. I can only attempt to solve this if your provide me with a certificate to debug with.

@ghost
Copy link
Author

ghost commented Sep 17, 2014

Hi @tsenart

It is impossible for me to provide you with a BBC cert, so the options are:

  1. I create a web application that uses SSL certification and generate my own certs
  2. Try to debug it myself.

I am learning Go at the moment, so I will have a go at debugging it myself (but it may take some time).

Many Thanks

Aidy

ps https://github.com/BBC/load-test-artefacts#vegeta

@ghost
Copy link
Author

ghost commented Sep 17, 2014

I see in your tests you have a cert.pem and a key.pem. Do I need to pass these files separately? Also do I not need a ca.pem?

@tsenart
Copy link
Owner

tsenart commented Sep 17, 2014

What do you mean, you have to pass these files directly? Have a look at http://golang.org/pkg/crypto/tls/#LoadX509KeyPair which would be used for a server.

@ghost
Copy link
Author

ghost commented Sep 17, 2014

It looks like we need to pass the public cert file and the private key separately. I currently have them bundled in one pem.

So wouldn't we need to do:
-certs public-cert.pem, private-key.pem

Which then get passed into LoadX509KeyPair function?

Aidy

@pascalhofmann
Copy link

vegeta does not support ssl client certs.
See https://golang.org/pkg/crypto/tls/#Config

    // Certificates contains one or more certificate chains
    // to present to the other side of the connection.
    // Server configurations must include at least one certificate.
    Certificates []Certificate

but vegeta sets:

    // RootCAs defines the set of root certificate authorities
    // that clients use when verifying server certificates.
    // If RootCAs is nil, TLS uses the host's root CA set.
    RootCAs *x509.CertPool

@tsenart tsenart reopened this Jun 19, 2015
@tsenart
Copy link
Owner

tsenart commented Jun 19, 2015

@pascalhofmann: Contributions welcome! I'm quite busy the following weeks... :-)

@pascalhofmann
Copy link

Sorry, I'm very busy too. :(

I ended up deactivating the client certificate check for the load testing…

@ghost
Copy link
Author

ghost commented Nov 9, 2015

Is this just a matter of swapping the correct library in?

tsenart added a commit that referenced this issue Nov 14, 2015
@tsenart
Copy link
Owner

tsenart commented Nov 14, 2015

@aidylewis: Would you mind building this branch and trying it out?

tsenart added a commit that referenced this issue Nov 14, 2015
tsenart added a commit that referenced this issue Nov 14, 2015
tsenart added a commit that referenced this issue Nov 14, 2015
@ghost
Copy link
Author

ghost commented Nov 15, 2015

Hi @tsenart

Brilliant. I will test it out tomorrow, while I am at work.

@tsenart
Copy link
Owner

tsenart commented Nov 16, 2015

@aidylewis: Any luck?

@ghost
Copy link
Author

ghost commented Nov 17, 2015

I can connect through wget, but not through vegata

$ Downloads wget --certificate=dev-cert.pem  "https://repo.dev.bbc.co.uk/load-test-team/cloud-load-test/trunk/project.json"
--2015-11-17 14:09:51--  https://repo.dev.bbc.co.uk/load-test-team/cloud-load-test/trunk/project.json
Resolving repo.dev.bbc.co.uk... 212.58.247.19
Connecting to repo.dev.bbc.co.uk|212.58.247.19|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 175 [text/plain]
Saving to: 'project.json'

project.json                                                        100%[=====================================================================================================================================================================>]     175  --.-KB/s   in 0s

2015-11-17 14:09:51 (4.91 MB/s) - 'project.json' saved [175/175]

$ Downloads echo "GET https://repo.dev.bbc.co.uk/load-test-team/cloud-load-test/trunk/project.json" | ./vegeta attack -duration=2s -cert=dev-cert.pem | tee results.bin | ./vegeta report
Requests      [total, rate]            100, 50.51
Duration      [total, attack, wait]    6.043667687s, 1.97999991s, 4.063667777s
Latencies     [mean, 50, 95, 99, max]  5.004173227s, 5.019698473s, 5.847646365s, 5.982105909s, 6.009408941s
Bytes In      [total, mean]            0, 0.00
Bytes Out     [total, mean]            0, 0.00
Success       [ratio]                  0.00%
Status Codes  [code:count]             0:100
Error Set:
Get https://repo.dev.bbc.co.uk/load-test-team/cloud-load-test/trunk/project.json: remote error: handshake failure

@tsenart
Copy link
Owner

tsenart commented Nov 17, 2015

OK, let's try to figure this out over chat: https://gitter.im/tsenart/vegeta

@ghost
Copy link
Author

ghost commented Nov 17, 2015

After @tsenart fix, I converted a p12 to a pem with the openssl command:

openssl pkcs12 -nodes -in /path/to/my/cert.p12 -out /pathto/my/cert.pem

This bundles the private key and public cert in the pem.

I then ran:

echo "GET https://whatever" | ./vegeta attack -duration=2s -cert=dev-cert.p12 -key=dev-cert.12 | tee results.bin | ./vegeta report

@ghost ghost closed this as completed Nov 17, 2015
tsenart added a commit that referenced this issue Nov 17, 2015
@tsenart tsenart reopened this Nov 17, 2015
@tsenart
Copy link
Owner

tsenart commented Nov 17, 2015

@aidylewis: Can you download the pre release binaries again and try to use it without specifying the -key flag?

@ghost
Copy link
Author

ghost commented Nov 17, 2015

OK

tsenart added a commit that referenced this issue Nov 17, 2015
tsenart added a commit that referenced this issue Nov 17, 2015
@ghost
Copy link
Author

ghost commented Nov 17, 2015

Yep, works

Downloads echo "GET https://repo.dev.bbc.co.uk/load-test-team/cloud-load-test/trunk/project.json" | ./vegeta attack -duration=2s -cert=dev-cert.pem | tee results.bin | ./vegeta report
Requests      [total, rate]            100, 50.51
Duration      [total, attack, wait]    2.042449332s, 1.979999923s, 62.449409ms
Latencies     [mean, 50, 95, 99, max]  63.527419ms, 60.675998ms, 79.496796ms, 100.795968ms, 125.271955ms
Bytes In      [total, mean]            17500, 175.00
Bytes Out     [total, mean]            0, 0.00
Success       [ratio]                  100.00%
Status Codes  [code:count]             200:100
Error Set:

Thanks for all you help @tsenart

@tsenart
Copy link
Owner

tsenart commented Nov 17, 2015

Great! :)

@tsenart
Copy link
Owner

tsenart commented Nov 17, 2015

And sorry for taking more than a year (!!!) to fix this.

tsenart added a commit that referenced this issue Nov 17, 2015
@ghost ghost reopened this Nov 17, 2015
tsenart added a commit that referenced this issue Nov 17, 2015
@ghost
Copy link
Author

ghost commented Nov 26, 2015

Hi @tsenart

I am receiving this error on a site: "x509: certificate signed by unknown authority"

Do I need to pass a ca.pem as well?

@tsenart
Copy link
Owner

tsenart commented Nov 26, 2015

That means that site's certificate isn't signed by any of the trusted CAs in your system. If you open that site in your browser, is it trusted?

@ghost
Copy link
Author

ghost commented Nov 26, 2015

Good point. No.

@tsenart
Copy link
Owner

tsenart commented Nov 26, 2015

Well, then, what is the expected behaviour for you? Would you want a flag that disables certificate verification?

@ghost
Copy link
Author

ghost commented Nov 26, 2015

I was too shy to ask, but that'd be nice.

In return I could write a BBC technology blog that includes Vegeta if you were interested and I don't mind giving a recurring "tip" as a thank you for your work.

@tsenart
Copy link
Owner

tsenart commented Nov 26, 2015

Hehe, don't be shy! You didn't need to offer me such thing, but I won't say
no :-) I'll try to have something ready by tomorrow.

On Thu, 26 Nov 2015 at 19:44, aidylewis notifications@github.com wrote:

I was too shy to ask, but that'd be nice.

In return I could write a BBC technology blog that includes Vegeta if you
were interested and I don't mind giving a recurring "tip" as a thank you
for your work.


Reply to this email directly or view it on GitHub
#63 (comment).

@ghost
Copy link
Author

ghost commented Nov 26, 2015

I'll ping you offline about the blog.

@ghost
Copy link
Author

ghost commented Nov 27, 2015

Hi @tsenart

I cannot find your email on the internet. Mine is adrian dot lewis at bbc dot co dot uk.

@sattishv
Copy link

Even i am facing the same issue ."x509: certificate has expired or is not yet valid: current time". Tried accepting the certificates through browser to make it trusted but it didnt . Is the disable SSL verification option available in vegeta. Can you please calrify

@stephenwsun
Copy link

@sattishv I believe the flag that you need to disable SSL verification is insecure. Set -insecure=true and that should work for you.

@sattishv
Copy link

sattishv commented Mar 3, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants