Skip to content

Commit

Permalink
Add links in doc comments
Browse files Browse the repository at this point in the history
This will be supported in Go 1.19.
  • Loading branch information
AGWA committed Jun 10, 2022
1 parent 18dc7b9 commit 426fe5a
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions pkcs12.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ func unmarshal(in []byte, out interface{}) error {
//
// Deprecated: ToPEM creates invalid PEM blocks (private keys
// are encoded as raw RSA or EC private keys rather than PKCS#8 despite being
// labeled "PRIVATE KEY"). To decode a PKCS#12 file, use DecodeChain instead,
// and use the encoding/pem package to convert to PEM if necessary.
// labeled "PRIVATE KEY"). To decode a PKCS#12 file, use [DecodeChain] instead,
// and use the [encoding/pem] package to convert to PEM if necessary.
func ToPEM(pfxData []byte, password string) ([]*pem.Block, error) {
encodedPassword, err := bmpStringZeroTerminated(password)
if err != nil {
Expand Down Expand Up @@ -248,7 +248,7 @@ func convertAttribute(attribute *pkcs12Attribute) (key, value string, err error)
// Decode extracts a certificate and private key from pfxData, which must be a DER-encoded PKCS#12 file. This function
// assumes that there is only one certificate and only one private key in the
// pfxData. Since PKCS#12 files often contain more than one certificate, you
// probably want to use DecodeChain instead.
// probably want to use [DecodeChain] instead.
func Decode(pfxData []byte, password string) (privateKey interface{}, certificate *x509.Certificate, err error) {
var caCerts []*x509.Certificate
privateKey, certificate, caCerts, err = DecodeChain(pfxData, password)
Expand Down Expand Up @@ -445,11 +445,11 @@ func getSafeContents(p12Data, password []byte, expectedItems int) (bags []safeBa
//
// The private key is encrypted with the provided password, but due to the
// weak encryption primitives used by PKCS#12, it is RECOMMENDED that you
// specify a hard-coded password (such as pkcs12.DefaultPassword) and protect
// specify a hard-coded password (such as [DefaultPassword]) and protect
// the resulting pfxData using other means.
//
// The rand argument is used to provide entropy for the encryption, and
// can be set to rand.Reader from the crypto/rand package.
// can be set to [crypto/rand.Reader].
//
// Encode emulates the behavior of OpenSSL's PKCS12_create: it creates two
// SafeContents: one that's encrypted with RC2 and contains the certificates,
Expand Down Expand Up @@ -546,11 +546,11 @@ func Encode(rand io.Reader, privateKey interface{}, certificate *x509.Certificat
// allow it to be used as a Java TrustStore in Java 1.8 and newer.
//
// Due to the weak encryption primitives used by PKCS#12, it is RECOMMENDED that
// you specify a hard-coded password (such as pkcs12.DefaultPassword) and protect
// you specify a hard-coded password (such as [DefaultPassword]) and protect
// the resulting pfxData using other means.
//
// The rand argument is used to provide entropy for the encryption, and
// can be set to rand.Reader from the crypto/rand package.
// can be set to [crypto/rand.Reader].
//
// EncodeTrustStore creates a single SafeContents that's encrypted with RC2
// and contains the certificates.
Expand All @@ -559,7 +559,7 @@ func Encode(rand io.Reader, privateKey interface{}, certificate *x509.Certificat
// within the resulting pfxData. If certificates share a Subject, then the
// resulting Friendly Names (Aliases) will be identical, which Java may treat as
// the same entry when used as a Java TrustStore, e.g. with `keytool`. To
// customize the Friendly Names, use EncodeTrustStoreEntries.
// customize the Friendly Names, use [EncodeTrustStoreEntries].
func EncodeTrustStore(rand io.Reader, certs []*x509.Certificate, password string) (pfxData []byte, err error) {
var certsWithFriendlyNames []TrustStoreEntry
for _, cert := range certs {
Expand All @@ -581,7 +581,7 @@ type TrustStoreEntry struct {
// certificates (entries) to be trusted. The certificates will be marked with a
// special OID that allow it to be used as a Java TrustStore in Java 1.8 and newer.
//
// This is identical to EncodeTrustStore, but also allows for setting specific
// This is identical to [EncodeTrustStore], but also allows for setting specific
// Friendly Names (Aliases) to be used per certificate, by specifying a slice
// of TrustStoreEntry.
//
Expand All @@ -590,11 +590,11 @@ type TrustStoreEntry struct {
// may treat as the same entry when used as a Java TrustStore, e.g. with `keytool`.
//
// Due to the weak encryption primitives used by PKCS#12, it is RECOMMENDED that
// you specify a hard-coded password (such as pkcs12.DefaultPassword) and protect
// you specify a hard-coded password (such as [DefaultPassword]) and protect
// the resulting pfxData using other means.
//
// The rand argument is used to provide entropy for the encryption, and
// can be set to rand.Reader from the crypto/rand package.
// can be set to [crypto/rand.Reader].
//
// EncodeTrustStoreEntries creates a single SafeContents that's encrypted
// with RC2 and contains the certificates.
Expand Down

0 comments on commit 426fe5a

Please sign in to comment.