mssql sqlserver 修改非对称密钥相关属性的方法分享


摘要:
下文讲述使用关键字Alter ASYMMETRIC KEY 关键字修改非对称密钥属性的方法分享,如下所示:
实验环境:sqlserver 2008 R2



ALTER ASYMMETRIC KEY 关键字简介

ALTER ASYMMETRIC KEY 关键字功能:
修改非对称加密的相关属性

ALTER ASYMMETRIC KEY 关键字语法说明:

ALTER ASYMMETRIC KEY Asym_Key_Name

::= | REMOVE PRIVATE KEY

::=
WITH PRIVATE KEY ( [ , ] )

::=
ENCRYPTION BY PASSWORD = ‘strongPassword’
| DECRYPTION BY PASSWORD = ‘oldPassword’
——-参数说明——
Asym_Key_Name:
非对称密钥定义时所使用的 密钥名称
REMOVE PRIVATE KEY
将非对称密钥中的私钥删除,保留公钥。
WITH PRIVATE KEY
修改私钥保护方式
ENCRYPTION BY PASSWORD =’strongPassword’
修改私钥所对应的新密码,输入的密码必须符合windows的密码策略。
DECRYPTION BY PASSWORD =’oldPassword’
私钥所对应的旧密码



ALTER ASYMMETRIC KEY 关键字举例应用

例1:
修改私钥密码

     
ALTER ASYMMETRIC KEY testKey    
    WITH PRIVATE KEY (  
    DECRYPTION BY PASSWORD = '',  
    ENCRYPTION BY PASSWORD = '');  
GO 


ALTER ASYMMETRIC KEY testKey    
    WITH PRIVATE KEY (  
    DECRYPTION BY PASSWORD = 'abcwewe_AL',  
    ENCRYPTION BY PASSWORD = 'abcwewe_AL123');  
GO 
  

例2:
删除非对称密钥testKey中的私钥,保留公钥

    ALTER ASYMMETRIC KEY testKey REMOVE PRIVATE KEY;  
     GO  

例3:
从私钥中删除密码保护

    OPEN MASTER KEY;  
      ALTER ASYMMETRIC KEY PacificSales09 WITH PRIVATE KEY (  
       DECRYPTION BY PASSWORD = '' );  
     GO
	 


OPEN MASTER KEY;  
      ALTER ASYMMETRIC KEY PacificSales09 WITH PRIVATE KEY (  
       DECRYPTION BY PASSWORD = 'abcwewe_AL123' );  
     GO