mirror of
https://github.com/libp2p/go-openssl.git
synced 2025-02-06 06:30:08 +08:00
Adding AddChainCertificate func
This commit is contained in:
parent
0022daa4f4
commit
85a1dc3167
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);
|
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
|
#ifndef SSL_MODE_RELEASE_BUFFERS
|
||||||
#define SSL_MODE_RELEASE_BUFFERS 0
|
#define SSL_MODE_RELEASE_BUFFERS 0
|
||||||
#endif
|
#endif
|
||||||
@ -205,6 +209,17 @@ func (c *Ctx) UseCertificate(cert *Certificate) error {
|
|||||||
return nil
|
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
|
// UsePrivateKey configures the context to use the given private key for SSL
|
||||||
// handshakes.
|
// handshakes.
|
||||||
func (c *Ctx) UsePrivateKey(key PrivateKey) error {
|
func (c *Ctx) UsePrivateKey(key PrivateKey) error {
|
||||||
|
Loading…
Reference in New Issue
Block a user