共用方式為


X509Certificate Class

Definition

Abstract class for X.

[Android.Runtime.Register("javax/security/cert/X509Certificate", DoNotGenerateAcw=true)]
public abstract class X509Certificate : Javax.Security.Cert.Certificate
[<Android.Runtime.Register("javax/security/cert/X509Certificate", DoNotGenerateAcw=true)>]
type X509Certificate = class
    inherit Certificate
Inheritance
X509Certificate
Attributes

Remarks

Abstract class for X.509 v1 certificates. This provides a standard way to access all the version 1 attributes of an X.509 certificate. Attributes that are specific to X.509 v2 or v3 are not available through this interface. Future API evolution will provide full access to complete X.509 v3 attributes.

The basic X.509 format was defined by ISO/IEC and ANSI X9 and is described below in ASN.1:

Certificate  ::=  SEQUENCE  {
                tbsCertificate       TBSCertificate,
                signatureAlgorithm   AlgorithmIdentifier,
                signature            BIT STRING  }

These certificates are widely used to support authentication and other functionality in Internet security systems. Common applications include Privacy Enhanced Mail (PEM), Transport Layer Security (SSL), code signing for trusted software distribution, and Secure Electronic Transactions (SET).

These certificates are managed and vouched for by <em>Certificate Authorities</em> (CAs). CAs are services which create certificates by placing data in the X.509 standard format and then digitally signing that data. CAs act as trusted third parties, making introductions between principals who have no direct knowledge of each other. CA certificates are either signed by themselves, or by some other CA such as a "root" CA.

The ASN.1 definition of tbsCertificate is:

TBSCertificate  ::=  SEQUENCE  {
                version         [0]  EXPLICIT Version DEFAULT v1,
                serialNumber         CertificateSerialNumber,
                signature            AlgorithmIdentifier,
                issuer               Name,
                validity             Validity,
                subject              Name,
                subjectPublicKeyInfo SubjectPublicKeyInfo,
                }

Here is sample code to instantiate an X.509 certificate:

InputStream inStream = new FileInputStream("fileName-of-cert");
            X509Certificate cert = X509Certificate.getInstance(inStream);
            inStream.close();

OR

byte[] certData = &lt;certificate read from a file, say&gt;
            X509Certificate cert = X509Certificate.getInstance(certData);

In either case, the code that instantiates an X.509 certificate consults the value of the cert.provider.x509v1 security property to locate the actual implementation or instantiates a default implementation.

The cert.provider.x509v1 property is set to a default implementation for X.509 such as:

cert.provider.x509v1=com.sun.security.cert.internal.x509.X509V1CertImpl

The value of this cert.provider.x509v1 property has to be changed to instantiate another implementation. If this security property is not set, a default implementation will be used. Currently, due to possible security restrictions on access to Security properties, this value is looked up and cached at class initialization time and will fallback on a default implementation if the Security property is not accessible.

<em>Note: The classes in the package javax.security.cert exist for compatibility with earlier versions of the Java Secure Sockets Extension (JSSE). New applications should instead use the standard Java SE certificate classes located in java.security.cert.</em>

Added in 1.4.

Java documentation for javax.security.cert.X509Certificate.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Constructors

X509Certificate()

Creates a new X509Certificate.

X509Certificate(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

Properties

Class

Returns the runtime class of this Object.

(Inherited from Object)
Handle

The handle to the underlying Android instance.

(Inherited from Object)
IssuerDN

Returns the issuer (issuer distinguished name) as an implementation specific Principal object.

JniIdentityHashCode (Inherited from Object)
JniPeerMembers
NotAfter

Returns the notAfter date of the validity period of the certificate.

NotBefore

Returns the notBefore date from the validity period of the certificate.

PeerReference (Inherited from Object)
PublicKey

Returns the public key corresponding to this certificate.

(Inherited from Certificate)
SerialNumber

Returns the serialNumber of the certificate.

SigAlgName

Returns the name of the algorithm for the certificate signature.

SigAlgOID

Returns the OID of the signature algorithm from the certificate.

SubjectDN

Returns the subject (subject distinguished name) as an implementation specific Principal object.

ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Version

Returns the certificates version (version number).

Methods

CheckValidity()

Checks that the certificate is currently valid.

CheckValidity(Date)

Checks that the specified date is within the certificate's validity period.

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
GetEncoded()

Returns the encoded form of this certificate.

(Inherited from Certificate)
GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
GetInstance(Byte[])

Instantiates an X509Certificate object, and initializes it with the specified byte array.

GetInstance(Stream)

Instantiates an X509Certificate object, and initializes it with the data read from the input stream inStream.

GetInstanceAsync(Byte[])
GetInstanceAsync(Stream)
GetSigAlgParams()

Gets the DER-encoded signature algorithm parameters from this certificate's signature algorithm.

JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
ToArray<T>() (Inherited from Object)
ToString()

Returns a string representation of this certificate.

(Inherited from Certificate)
UnregisterFromRuntime() (Inherited from Object)
Verify(IPublicKey, String)

Verifies that this certificate was signed using the private key that corresponds to the specified public key.

(Inherited from Certificate)
Verify(IPublicKey)

Verifies that this certificate was signed using the private key that corresponds to the specified public key.

(Inherited from Certificate)
Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to