本文整理汇总了Java中org.bouncycastle.asn1.x509.X509CertificateStructure.getSubjectPublicKeyInfo方法的典型用法代码示例。如果您正苦于以下问题:Java X509CertificateStructure.getSubjectPublicKeyInfo方法的具体用法?Java X509CertificateStructure.getSubjectPublicKeyInfo怎么用?Java X509CertificateStructure.getSubjectPublicKeyInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bouncycastle.asn1.x509.X509CertificateStructure
的用法示例。
在下文中一共展示了X509CertificateStructure.getSubjectPublicKeyInfo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processServerCertificate
import org.bouncycastle.asn1.x509.X509CertificateStructure; //导入方法依赖的package包/类
public void processServerCertificate(Certificate serverCertificate) throws IOException
{
X509CertificateStructure x509Cert = serverCertificate.certs[0];
SubjectPublicKeyInfo keyInfo = x509Cert.getSubjectPublicKeyInfo();
try
{
this.serverPublicKey = PublicKeyFactory.createKey(keyInfo);
}
catch (RuntimeException e)
{
handler.failWithError(TlsProtocolHandler.AL_fatal,
TlsProtocolHandler.AP_unsupported_certificate);
}
// Sanity check the PublicKeyFactory
if (this.serverPublicKey.isPrivate())
{
handler.failWithError(TlsProtocolHandler.AL_fatal, TlsProtocolHandler.AP_internal_error);
}
// TODO
/*
* Perform various checks per RFC2246 7.4.2: "Unless otherwise specified, the
* signing algorithm for the certificate must be the same as the algorithm for the
* certificate key."
*/
// TODO Should the 'instanceof' tests be replaces with stricter checks on keyInfo.getAlgorithmId()?
if (!(this.serverPublicKey instanceof RSAKeyParameters))
{
handler.failWithError(TlsProtocolHandler.AL_fatal,
TlsProtocolHandler.AP_certificate_unknown);
}
validateKeyUsage(x509Cert, KeyUsage.keyEncipherment);
this.rsaServerPublicKey = validateRSAPublicKey((RSAKeyParameters)this.serverPublicKey);
/*
* Verify them.
*/
if (!this.verifyer.isValid(serverCertificate.getCerts()))
{
handler.failWithError(TlsProtocolHandler.AL_fatal, TlsProtocolHandler.AP_user_canceled);
}
}
示例2: processServerCertificate
import org.bouncycastle.asn1.x509.X509CertificateStructure; //导入方法依赖的package包/类
public void processServerCertificate(Certificate serverCertificate) throws IOException
{
X509CertificateStructure x509Cert = serverCertificate.certs[0];
SubjectPublicKeyInfo keyInfo = x509Cert.getSubjectPublicKeyInfo();
try
{
this.serverPublicKey = PublicKeyFactory.createKey(keyInfo);
}
catch (RuntimeException e)
{
handler.failWithError(TlsProtocolHandler.AL_fatal,
TlsProtocolHandler.AP_unsupported_certificate);
}
// Sanity check the PublicKeyFactory
if (this.serverPublicKey.isPrivate())
{
handler.failWithError(TlsProtocolHandler.AL_fatal, TlsProtocolHandler.AP_internal_error);
}
// TODO
/*
* Perform various checks per RFC2246 7.4.2: "Unless otherwise specified, the
* signing algorithm for the certificate must be the same as the algorithm for the
* certificate key."
*/
// TODO Should the 'instanceof' tests be replaces with stricter checks on keyInfo.getAlgorithmId()?
switch (this.keyExchange)
{
case TlsKeyExchange.KE_DH_DSS:
if (!(this.serverPublicKey instanceof DHPublicKeyParameters))
{
handler.failWithError(TlsProtocolHandler.AL_fatal,
TlsProtocolHandler.AP_certificate_unknown);
}
// TODO The algorithm used to sign the certificate should be DSS.
// x509Cert.getSignatureAlgorithm();
this.dhAgreeServerPublicKey = validateDHPublicKey((DHPublicKeyParameters)this.serverPublicKey);
break;
case TlsKeyExchange.KE_DH_RSA:
if (!(this.serverPublicKey instanceof DHPublicKeyParameters))
{
handler.failWithError(TlsProtocolHandler.AL_fatal,
TlsProtocolHandler.AP_certificate_unknown);
}
// TODO The algorithm used to sign the certificate should be RSA.
// x509Cert.getSignatureAlgorithm();
this.dhAgreeServerPublicKey = validateDHPublicKey((DHPublicKeyParameters)this.serverPublicKey);
break;
case TlsKeyExchange.KE_DHE_RSA:
if (!(this.serverPublicKey instanceof RSAKeyParameters))
{
handler.failWithError(TlsProtocolHandler.AL_fatal,
TlsProtocolHandler.AP_certificate_unknown);
}
validateKeyUsage(x509Cert, KeyUsage.digitalSignature);
break;
case TlsKeyExchange.KE_DHE_DSS:
if (!(this.serverPublicKey instanceof DSAPublicKeyParameters))
{
handler.failWithError(TlsProtocolHandler.AL_fatal,
TlsProtocolHandler.AP_certificate_unknown);
}
break;
default:
handler.failWithError(TlsProtocolHandler.AL_fatal,
TlsProtocolHandler.AP_unsupported_certificate);
}
/*
* Verify them.
*/
if (!this.verifyer.isValid(serverCertificate.getCerts()))
{
handler.failWithError(TlsProtocolHandler.AL_fatal, TlsProtocolHandler.AP_user_canceled);
}
}
示例3: processServerCertificate
import org.bouncycastle.asn1.x509.X509CertificateStructure; //导入方法依赖的package包/类
public void processServerCertificate(Certificate serverCertificate) throws IOException
{
if (tlsSigner == null)
{
handler.failWithError(TlsProtocolHandler.AL_fatal,
TlsProtocolHandler.AP_unexpected_message);
}
X509CertificateStructure x509Cert = serverCertificate.certs[0];
SubjectPublicKeyInfo keyInfo = x509Cert.getSubjectPublicKeyInfo();
try
{
this.serverPublicKey = PublicKeyFactory.createKey(keyInfo);
}
catch (RuntimeException e)
{
handler.failWithError(TlsProtocolHandler.AL_fatal,
TlsProtocolHandler.AP_unsupported_certificate);
}
// Sanity check the PublicKeyFactory
if (this.serverPublicKey.isPrivate())
{
handler.failWithError(TlsProtocolHandler.AL_fatal, TlsProtocolHandler.AP_internal_error);
}
// TODO
/*
* Perform various checks per RFC2246 7.4.2: "Unless otherwise specified, the
* signing algorithm for the certificate must be the same as the algorithm for the
* certificate key."
*/
switch (this.keyExchange)
{
case TlsKeyExchange.KE_SRP_RSA:
if (!(this.serverPublicKey instanceof RSAKeyParameters))
{
handler.failWithError(TlsProtocolHandler.AL_fatal,
TlsProtocolHandler.AP_certificate_unknown);
}
validateKeyUsage(x509Cert, KeyUsage.digitalSignature);
break;
case TlsKeyExchange.KE_SRP_DSS:
if (!(this.serverPublicKey instanceof DSAPublicKeyParameters))
{
handler.failWithError(TlsProtocolHandler.AL_fatal,
TlsProtocolHandler.AP_certificate_unknown);
}
break;
default:
handler.failWithError(TlsProtocolHandler.AL_fatal,
TlsProtocolHandler.AP_unsupported_certificate);
}
/*
* Verify them.
*/
if (!this.verifyer.isValid(serverCertificate.getCerts()))
{
handler.failWithError(TlsProtocolHandler.AL_fatal, TlsProtocolHandler.AP_user_canceled);
}
}