Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/324.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 复制在Go中创建的CRL_Java_Go_X509_Pki_Certificate Revocation - Fatal编程技术网

Java 复制在Go中创建的CRL

Java 复制在Go中创建的CRL,java,go,x509,pki,certificate-revocation,Java,Go,X509,Pki,Certificate Revocation,我在Go中创建了一个CRL(将其解析为PEM),现在我想在Java中重新创建完全相同的CRL(以获得相同的PEM)。然而,我不知道如何做到这一点,我发现Go和Java中的CRL类非常不同 我通过以下方式在Golang创建了CRL: var revokedCerts []pkix.RevokedCertificate clientRevocation := pkix.RevokedCertificate{ SerialNumber: clientCert.SerialNumber,

我在Go中创建了一个CRL(将其解析为PEM),现在我想在Java中重新创建完全相同的CRL(以获得相同的PEM)。然而,我不知道如何做到这一点,我发现Go和Java中的CRL类非常不同

我通过以下方式在Golang创建了CRL:

var revokedCerts []pkix.RevokedCertificate

clientRevocation := pkix.RevokedCertificate{
    SerialNumber:   clientCert.SerialNumber,
    RevocationTime: timeToUseInRevocation.UTC(),
}

revokedCerts = append(revokedCerts, clientRevocation)


crlSubject := pkix.Name{
    Organization:  []string{"testorg", "TestOrg"},
    StreetAddress: []string{"TestAddress"},
    PostalCode:    []string{"0"},
    Province:      []string{"TestProvince"},
    Locality:      []string{"TestLocality"},
    Country:       []string{"TestCountry"},
    CommonName:    "Test Name",
}

var sigAlgorithm pkix.AlgorithmIdentifier
sigAlgorithm.Algorithm = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 1, 11}
sigAlgorithm.Parameters = asn1.NullRawValue

tbsCertList := pkix.TBSCertificateList{
    Version:             1,
    Signature:           sigAlgorithm,
    Issuer:              crlSubject.ToRDNSequence(),
    ThisUpdate:          timeToUseInRevocation,
    NextUpdate:          timeToUseInRevocation.Add(time.Millisecond * time.Duration(86400000)),
    RevokedCertificates: revokedCerts,
}
newCRL, err := asn1.Marshal(pkix.CertificateList{
    TBSCertList:        tbsCertList, // new CRL
    SignatureAlgorithm: sigAlgorithm,
    SignatureValue:     asn1.BitString{}, 
})
crlCreated, err := x509.ParseCRL(newCRL)

//CRL pem Block
crlPemBlock := &pem.Block{
    Type:  "X509 CRL",
    Bytes: newCRL,
}

var crlBuffer bytes.Buffer
err = pem.Encode(&crlBuffer, crlPemBlock)
我想用Java重现这一点。 我知道我的变量(例如crl签名)为空/零。那是为了我想做的事。 我可以使用PEM并读取Java中的CRL,但我无法创建完全相同的CRL

我想在Java中创建CRL,也不需要签名(所有参数都相等)