SQL Server
SQL Server
Duplicate openssl pkey -in private.pem -pubout -out pubkey.pem
See more OpenSSL Examples
How to output the public part of a private key: Demonstrates how to duplicate this OpenSSL command:openssl pkey -in private.pem -pubout -out pubkey.pem
Chilkat SQL Server Downloads
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
-- Important: Do not use nvarchar(max). See the warning about using nvarchar(max).
DECLARE @sTmp0 nvarchar(4000)
DECLARE @success int
SELECT @success = 0
DECLARE @pkey int
EXEC @hr = sp_OACreate 'Chilkat.PrivateKey', @pkey OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
-- Load the private key from an PEM file:
EXEC sp_OAMethod @pkey, 'LoadPemFile', @success OUT, 'private.pem'
IF @success = 0
BEGIN
EXEC sp_OAGetProperty @pkey, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @pkey
RETURN
END
DECLARE @pubKey int
EXEC @hr = sp_OACreate 'Chilkat.PublicKey', @pubKey OUT
EXEC sp_OAMethod @pkey, 'ToPublicKey', @success OUT, @pubKey
EXEC sp_OAMethod @pubKey, 'SavePemFile', @success OUT, 0, 'pubKey.pem'
IF @success <> 1
BEGIN
EXEC sp_OAGetProperty @pubKey, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @pubKey
EXEC @hr = sp_OADestroy @pkey
EXEC @hr = sp_OADestroy @pubKey
RETURN
END
PRINT 'Success.'
EXEC @hr = sp_OADestroy @pkey
EXEC @hr = sp_OADestroy @pubKey
END
GO