简体   繁体   English

将数据添加到X509证书

[英]Adding Data to X509 certificate

I have an user certificate field in LDAP, which accepts X509 certificate. 我在LDAP中有一个用户证书字段,该字段接受X509证书。 I have created an X509 certificate following the user guides available at bouncy castle wiki. 我已经按照充气城堡Wiki上的用户指南创建了X509证书。

The cerficate is created successfully and is added to LDAP. 证书已成功创建,并已添加到LDAP。 My requirement is that i have an ecrypted data for each user, which i need to save to the user certificate field. 我的要求是每个用户都有一个加密的数据,我需要将其保存到用户证书字段中。

How can i add this data to the user certificate? 如何将此数据添加到用户证书?

I have created a Version 1 User certificate using the below code. 我使用以下代码创建了版本1用户证书。

Security.addProvider(new BouncyCastleProvider());

            KeyPairGenerator kpGen = KeyPairGenerator.getInstance("RSA", "BC");
            kpGen.initialize(1024, new SecureRandom());
            KeyPair pair = kpGen.generateKeyPair();

            X509v1CertificateBuilder certBldr = new JcaX509v1CertificateBuilder(
                    new X500Name("CN=User Certificate:"),
                    BigInteger.valueOf(1),
                    new Date(System.currentTimeMillis()),
                    new Date(System.currentTimeMillis() + (5*365*24*60*60*1000)),
                    new X500Name("CN=User Certificate:"),
                    pair.getPublic());
                    ContentSigner signer = new JcaContentSignerBuilder("SHA1withRSA")
                    .setProvider("BC").build(pair.getPrivate());

                cert= new JcaX509CertificateConverter().setProvider("BC")
                .getCertificate(certBldr.build(signer));

The cerficate is created successfully and is added to LDAP. 证书已成功创建,并已添加到LDAP。 My requirement is that i have an ecrypted data for each user, which i need to save to the user certificate field. 我的要求是每个用户都有一个加密的数据,我需要将其保存到用户证书字段中。

Something wrong there. 那里出了点问题。 The userCertificate attribute is for an X.509 certificate. userCertificate属性用于X.509证书。 Putting anything else in there would be an LDAP schema violation. 将其他内容放入其中将违反LDAP模式。

How can i add this data to the user certificate? 如何将此数据添加到用户证书?

You can't. 你不能

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM