Skip to content

Commit af8071e

Browse files
committed
Merge pull request #1 from zowens/add_chain
Adding AddChainCertificate func
2 parents 0022daa + 85a1dc3 commit af8071e

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

ctx.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ static int CRYPTO_add_not_a_macro(int *pointer,int amount,int type) {
4242
return CRYPTO_add(pointer, amount, type);
4343
}
4444
45+
static long SSL_CTX_add_extra_chain_cert_not_a_macro(SSL_CTX* ctx, X509 *cert) {
46+
return SSL_CTX_add_extra_chain_cert(ctx, cert);
47+
}
48+
4549
#ifndef SSL_MODE_RELEASE_BUFFERS
4650
#define SSL_MODE_RELEASE_BUFFERS 0
4751
#endif
@@ -205,6 +209,17 @@ func (c *Ctx) UseCertificate(cert *Certificate) error {
205209
return nil
206210
}
207211

212+
// AddChainCertificate adds a certificate to the chain presented in the
213+
// handshake.
214+
func (c *Ctx) AddChainCertificate(cert *Certificate) error {
215+
runtime.LockOSThread()
216+
defer runtime.UnlockOSThread()
217+
if int(C.SSL_CTX_add_extra_chain_cert_not_a_macro(c.ctx, cert.x)) != 1 {
218+
return errorFromErrorQueue()
219+
}
220+
return nil
221+
}
222+
208223
// UsePrivateKey configures the context to use the given private key for SSL
209224
// handshakes.
210225
func (c *Ctx) UsePrivateKey(key PrivateKey) error {

0 commit comments

Comments
 (0)