SQL Server
SQL Server
Use a Certificate Vault for Chain Building
See more PFX/P12 Examples
Demonstrates Pfx.UseCertVault, which adds the certificates in an XmlCertVault to the set of sources available for later chain-building operations such as AddCert.
The file path is relative to the application's current working directory. An absolute path may also be used. Supply the path appropriate to your own environment.
Background. The call captures a point-in-time snapshot of the vault's certificates. Providing extra intermediate certificates lets Chilkat complete certificate chains when building a PFX.
Chilkat SQL Server Downloads
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @sTmp0 nvarchar(4000)
DECLARE @success int
SELECT @success = 0
DECLARE @pfx int
EXEC @hr = sp_OACreate 'Chilkat.Pfx', @pfx OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
-- The file path is relative to the application's current working directory. An absolute path
-- may also be used. Supply the path appropriate to your own environment.
-- Load additional certificates (such as intermediate CA certificates) into a certificate vault.
DECLARE @vault int
EXEC @hr = sp_OACreate 'Chilkat.XmlCertVault', @vault OUT
EXEC sp_OAMethod @vault, 'AddCertFile', @success OUT, 'qa_data/intermediate_ca.cer'
IF @success = 0
BEGIN
EXEC sp_OAGetProperty @vault, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @pfx
EXEC @hr = sp_OADestroy @vault
RETURN
END
-- Make the vault's certificates available as sources for later chain-building operations, such as
-- AddCert. The call captures a point-in-time snapshot of the vault's certificates.
EXEC sp_OAMethod @pfx, 'UseCertVault', @success OUT, @vault
IF @success = 0
BEGIN
EXEC sp_OAGetProperty @pfx, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @pfx
EXEC @hr = sp_OADestroy @vault
RETURN
END
PRINT 'Certificate vault registered as a chain-building source.'
EXEC @hr = sp_OADestroy @pfx
EXEC @hr = sp_OADestroy @vault
END
GO