带有 X509 证书和属性证书的 JSCEP
JSCEP with X509Certificate and Attribute Certificate
我想将 JSCEP
与属性证书 (AC) 一起使用,它们是 X.509 的一部分。当我检查 Java 库时。在 java.security.cert
包中包含一个摘要 X509Certificate
但此证书继承了 java.security.cert.Certificate
的 getPublicKey
方法,它不是 AC 的一部分。
我的问题:
- 可以在没有 public 键的情况下使用
X509Certificate
。这样其他 java class 就不会出现像 JcaX509CertificateConverter
这样的问题了吗?
- 我是否应该实现自己的
AttributeCertificate
class,它不继承自 java.security.cert.Certificate
?
- 最佳实践方法是什么?
X509Certificate
class表示Public密钥证书(PKC),而属性证书 (AC),虽然它是一个类似(但不是那么多)的结构,但没有 public 键。而且它们不是一回事。
A X509Certificate
不能在没有 public 键的情况下使用,因为键是它的一部分。如果您查看 RFC's definition,您会发现它是必填字段:
Certificate ::= SEQUENCE {
tbsCertificate TBSCertificate,
signatureAlgorithm AlgorithmIdentifier,
signatureValue BIT STRING }
TBSCertificate ::= SEQUENCE {
... lots of fields...
subjectPublicKeyInfo SubjectPublicKeyInfo,
... }
SubjectPublicKeyInfo ::= SEQUENCE {
algorithm AlgorithmIdentifier,
subjectPublicKey BIT STRING }
public 密钥也是 PKC 定义的一部分:绑定身份和 public 密钥的东西,如 stated in the RFC:
...public key certificates, which are data structures that bind
public key values to subjects
Attribute Certificates 在 this RFC 中定义,它说明了与 PKC 的区别:
Some people constantly confuse PKCs and ACs. An analogy may make
the distinction clear. A PKC can be considered to be like a
passport: it identifies the holder, tends to last for a long time,
and should not be trivial to obtain. An AC is more like an entry
visa: it is typically issued by a different authority and does not
last for as long a time. As acquiring an entry visa typically
requires presenting a passport, getting a visa can be a simpler
process.
在同一页中,您可以看到 AC's structure is very different from a PKC,因此 AC 的实现不应继承自 X509Certificate
。虽然有一些相似的领域,但我认为它们还不够接近以证明继承的合理性(而且它们也有不同的目的和用途,这让我完全放弃继承)。
针对您的情况的最佳方法:我建议使用现有的实现。 BouncyCastle is one of them. If you can't use an external lib, you can use BouncyCastle's code作为参考。
我想将 JSCEP
与属性证书 (AC) 一起使用,它们是 X.509 的一部分。当我检查 Java 库时。在 java.security.cert
包中包含一个摘要 X509Certificate
但此证书继承了 java.security.cert.Certificate
的 getPublicKey
方法,它不是 AC 的一部分。
我的问题:
- 可以在没有 public 键的情况下使用
X509Certificate
。这样其他 java class 就不会出现像JcaX509CertificateConverter
这样的问题了吗? - 我是否应该实现自己的
AttributeCertificate
class,它不继承自java.security.cert.Certificate
? - 最佳实践方法是什么?
X509Certificate
class表示Public密钥证书(PKC),而属性证书 (AC),虽然它是一个类似(但不是那么多)的结构,但没有 public 键。而且它们不是一回事。
A X509Certificate
不能在没有 public 键的情况下使用,因为键是它的一部分。如果您查看 RFC's definition,您会发现它是必填字段:
Certificate ::= SEQUENCE {
tbsCertificate TBSCertificate,
signatureAlgorithm AlgorithmIdentifier,
signatureValue BIT STRING }
TBSCertificate ::= SEQUENCE {
... lots of fields...
subjectPublicKeyInfo SubjectPublicKeyInfo,
... }
SubjectPublicKeyInfo ::= SEQUENCE {
algorithm AlgorithmIdentifier,
subjectPublicKey BIT STRING }
public 密钥也是 PKC 定义的一部分:绑定身份和 public 密钥的东西,如 stated in the RFC:
...public key certificates, which are data structures that bind public key values to subjects
Attribute Certificates 在 this RFC 中定义,它说明了与 PKC 的区别:
Some people constantly confuse PKCs and ACs. An analogy may make the distinction clear. A PKC can be considered to be like a passport: it identifies the holder, tends to last for a long time, and should not be trivial to obtain. An AC is more like an entry visa: it is typically issued by a different authority and does not last for as long a time. As acquiring an entry visa typically requires presenting a passport, getting a visa can be a simpler process.
在同一页中,您可以看到 AC's structure is very different from a PKC,因此 AC 的实现不应继承自 X509Certificate
。虽然有一些相似的领域,但我认为它们还不够接近以证明继承的合理性(而且它们也有不同的目的和用途,这让我完全放弃继承)。
针对您的情况的最佳方法:我建议使用现有的实现。 BouncyCastle is one of them. If you can't use an external lib, you can use BouncyCastle's code作为参考。