Class P12KeyStore

java.lang.Object
org.fisco.bcos.sdk.crypto.keystore.KeyTool
org.fisco.bcos.sdk.crypto.keystore.P12KeyStore

public class P12KeyStore
extends KeyTool
  • Constructor Details

    • P12KeyStore

      public P12KeyStore​(java.lang.String keyStoreFile, java.lang.String password)
    • P12KeyStore

      public P12KeyStore​(java.io.InputStream keyStoreFileInputStream, java.lang.String password)
  • Method Details

    • getPublicKey

      public java.security.PublicKey getPublicKey()
      Specified by:
      getPublicKey in class KeyTool
    • load

      protected void load​(java.io.InputStream in)
      load keyPair from the given input stream
      Specified by:
      load in class KeyTool
      Parameters:
      in - the input stream that should used to load keyPair
    • getPrivateKey

      protected java.security.PrivateKey getPrivateKey()
      get private key from the keyStore
      Specified by:
      getPrivateKey in class KeyTool
      Returns:
      the private key
    • storeKeyPairWithP12Format

      public static void storeKeyPairWithP12Format​(java.lang.String hexedPrivateKey, java.lang.String password, java.lang.String privateKeyFilePath, java.lang.String curveName, java.lang.String signatureAlgorithm) throws SaveKeyStoreException
      Throws:
      SaveKeyStoreException
    • generateSelfSignedCertificate

      public static java.security.cert.X509Certificate generateSelfSignedCertificate​(java.security.KeyPair keyPair, java.lang.String signatureAlgorithm) throws java.security.NoSuchAlgorithmException, java.security.cert.CertificateEncodingException, java.security.NoSuchProviderException, java.security.InvalidKeyException, java.security.SignatureException
      generate self-signed certificate
      Parameters:
      keyPair - the keyPair used to generated the certificate
      signatureAlgorithm - the signature algorithm of the cert
      Returns:
      the generated self-signed certificate object
      Throws:
      java.security.NoSuchAlgorithmException - no such algorithm exception
      java.security.cert.CertificateEncodingException - error occurs when encoding certificate
      java.security.NoSuchProviderException - no such provider exception
      java.security.InvalidKeyException - invalid key exception
      java.security.SignatureException - generic signature exception