-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Appu Goundan <appu@google.com>
- Loading branch information
1 parent
f07e270
commit 372c938
Showing
6 changed files
with
117 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright 2022 The Sigstore Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package dev.sigstore; | ||
|
||
import dev.sigstore.rekor.client.RekorEntry; | ||
import java.security.cert.CertPath; | ||
import org.immutables.value.Value; | ||
|
||
@Value.Immutable | ||
public interface KeylessSigningResult { | ||
/** The full certificate chain provided by fulcio for the public key used to sign the artifact */ | ||
CertPath getCertPath(); | ||
|
||
/** The signature over the artifact */ | ||
byte[] getSignature(); | ||
|
||
/** The entry in the rekor transparency log */ | ||
RekorEntry getEntry(); | ||
} |
40 changes: 40 additions & 0 deletions
40
src/main/java/dev/sigstore/encryption/certificates/Certificates.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright 2022 The Sigstore Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package dev.sigstore.encryption.certificates; | ||
|
||
import java.io.IOException; | ||
import java.io.StringWriter; | ||
import java.nio.charset.StandardCharsets; | ||
import java.security.cert.Certificate; | ||
import org.bouncycastle.openssl.jcajce.JcaPEMWriter; | ||
|
||
public class Certificates { | ||
|
||
/** Convert a certificate to a PEM encoded certificate. */ | ||
public static String toPemString(Certificate cert) throws IOException { | ||
var certWriter = new StringWriter(); | ||
try (JcaPEMWriter pemWriter = new JcaPEMWriter(certWriter)) { | ||
pemWriter.writeObject(cert); | ||
pemWriter.flush(); | ||
} | ||
return certWriter.toString(); | ||
} | ||
|
||
/** Convert a certificate to a PEM encoded certificate. */ | ||
public static byte[] toPemBytes(Certificate cert) throws IOException { | ||
return toPemString(cert).getBytes(StandardCharsets.UTF_8); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters