Revise API to load cert/key in SSLContext.
authorXiangyu Bu <xbu@fb.com>
Mon, 27 Nov 2017 23:37:45 +0000 (15:37 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Mon, 27 Nov 2017 23:50:50 +0000 (15:50 -0800)
commit3e19d28a142149241d81c5e736aa4117fe7cbec8
tree0d32d8adee7385377f9d1e62ab44e2da233256f6
parent36ac103264634cafe2944c33a9677ce9a8b2ac2d
Revise API to load cert/key in SSLContext.

Summary:
When loading cert/key pair, order matters:
(a) Wrong key will fail to load if a cert is loaded;
(b) Wrong cert will succeed to load even if a private key is loaded.

So this diff adds:
(1) SSLContext::checkPrivateKey() -- must call for case (b).
(2) SSLContext::loadCertKeyPairFromBufferPEM() -- use this if one loads both cert and key. Guaranteed to throw if cert/key mismatch.

Reviewed By: yfeldblum

Differential Revision: D6416280

fbshipit-source-id: 8ae370883d46e9b5afb69c506c09fbf7ba82b1b9
folly/io/async/SSLContext.cpp
folly/io/async/SSLContext.h
folly/io/async/test/SSLContextTest.cpp