Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x509: update go-generator #87

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 9 additions & 17 deletions x509/install.sh
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
#!/bin/bash

set -eu -o pipefail
shopt -s failglob

cp -a $(go env GOROOT)/src/crypto/x509/* ./
rm ./x509_test.go

# The following code is utterly horrifying. I can't find a better way to do it. :(
mkdir -p ${GOPATH}/src/vendor/golang.org/
cp -R $(go env GOROOT)/src/vendor/golang_org/* ${GOPATH}/src/vendor/golang.org/
# h/t to https://www.cyberciti.biz/faq/unix-linux-replace-string-words-in-many-files/
OLD_PACKAGE='"golang_org/x/crypto/cryptobyte'
OLD_PACKAGE="${OLD_PACKAGE//\//\\/}"
NEW_PACKAGE='"golang.org/x/crypto/cryptobyte'
NEW_PACKAGE="${NEW_PACKAGE//\//\\/}"
sed -i "s/${OLD_PACKAGE}/${NEW_PACKAGE}/g" ./*.go ${GOPATH}/src/vendor/golang.org/x/crypto/cryptobyte/*.go
#!/bin/sh
set -e
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I correct in inferring that the set -u, set -o pipefail, and shopt -s failglob were removed for compatibility with sh? I'm honestly not sure how I feel about this change; those options are useful from a safety perspective. @hlandau what do you think about this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes and, well, theres no piping going on so theres no need for pipefail

goroot="$(go env GOROOT)"
x509path=$goroot/src/crypto/x509
test -d $goroot
test -d $x509path
cp -av $x509path/* .
rm x509_test.go
sed -i.bak 's/golang_org/golang.org/g' x509.go
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like you've removed the copying of the cryptobyte package... is that copy actually unnecessary now? I seem to remember it being required when I was porting to Go 1.10.x, is that no longer the case?

Copy link
Author

@aerth aerth Oct 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no longer necessary it seems (go 1.11.1 here)

21 changes: 1 addition & 20 deletions x509/x509_splice.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// Last rebased on Go 1.10
// Remove all content between "import" and "CreateCertificate" in original.
// Remove all content after "CreateCertificate" in original.
//go:generate bash install.sh
//go:generate sh install.sh

// Package x509 parses X.509-encoded keys and certificates.
//
Expand All @@ -20,30 +20,11 @@ package x509

import (
"bytes"
//"crypto"
//"crypto/dsa"
//"crypto/ecdsa"
//"crypto/elliptic"
//"crypto/rsa"
_ "crypto/sha1"
_ "crypto/sha256"
_ "crypto/sha512"
//"crypto/x509/pkix"
"encoding/asn1"
//"encoding/pem"
"errors"
//"fmt"
//"io"
//"math/big"
//"net"
//"net/url"
//"strconv"
//"strings"
//"time"
//"unicode/utf8"
//
//"golang_org/x/crypto/cryptobyte"
//cryptobyte_asn1 "golang_org/x/crypto/cryptobyte/asn1"
)

// CreateCertificate creates a new X.509v3 certificate based on a template.
Expand Down