mirror of
https://github.com/libp2p/go-openssl.git
synced 2024-12-28 23:50:14 +08:00
Merge pull request #1 from zowens/add_chain
Adding AddChainCertificate func
This commit is contained in:
commit
af8071e04e
15
ctx.go
15
ctx.go
@ -42,6 +42,10 @@ static int CRYPTO_add_not_a_macro(int *pointer,int amount,int type) {
|
||||
return CRYPTO_add(pointer, amount, type);
|
||||
}
|
||||
|
||||
static long SSL_CTX_add_extra_chain_cert_not_a_macro(SSL_CTX* ctx, X509 *cert) {
|
||||
return SSL_CTX_add_extra_chain_cert(ctx, cert);
|
||||
}
|
||||
|
||||
#ifndef SSL_MODE_RELEASE_BUFFERS
|
||||
#define SSL_MODE_RELEASE_BUFFERS 0
|
||||
#endif
|
||||
@ -205,6 +209,17 @@ func (c *Ctx) UseCertificate(cert *Certificate) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// AddChainCertificate adds a certificate to the chain presented in the
|
||||
// handshake.
|
||||
func (c *Ctx) AddChainCertificate(cert *Certificate) error {
|
||||
runtime.LockOSThread()
|
||||
defer runtime.UnlockOSThread()
|
||||
if int(C.SSL_CTX_add_extra_chain_cert_not_a_macro(c.ctx, cert.x)) != 1 {
|
||||
return errorFromErrorQueue()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// UsePrivateKey configures the context to use the given private key for SSL
|
||||
// handshakes.
|
||||
func (c *Ctx) UsePrivateKey(key PrivateKey) error {
|
||||
|
Loading…
Reference in New Issue
Block a user