8000 goproxy/signer.go at master · rbarbaresco/goproxy · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
{"payload":{"allShortcutsEnabled":false,"fileTree":{"":{"items":[{"name":"certs","path":"certs","contentType":"directory"},{"name":"examples","path":"examples","contentType":"directory"},{"name":"ext","path":"ext","contentType":"directory"},{"name":"regretable","path":"regretable","contentType":"directory"},{"name":"test_data","path":"test_data","contentType":"directory"},{"name":"transport","path":"transport","contentType":"directory"},{"name":".gitignore","path":".gitignore","contentType":"file"},{"name":"LICENSE","path":"LICENSE","contentType":"file"},{"name":"README.md","path":"README.md","contentType":"file"},{"name":"actions.go","path":"actions.go","contentType":"file"},{"name":"all.bash","path":"all.bash","contentType":"file"},{"name":"ca.pem","path":"ca.pem","contentType":"file"},{"name":"certs.go","path":"certs.go","contentType":"file"},{"name":"chunked.go","path":"chunked.go","contentType":"file"},{"name":"counterecryptor.go","path":"counterecryptor.go","contentType":"file"},{"name":"counterecryptor_test.go","path":"counterecryptor_test.go","contentType":"file"},{"name":"ctx.go","path":"ctx.go","contentType":"file"},{"name":"dispatcher.go","path":"dispatcher.go","contentType":"file"},{"name":"doc.go","path":"doc.go","contentType":"file"},{"name":"https.go","path":"https.go","contentType":"file"},{"name":"key.pem","path":"key.pem","contentType":"file"},{"name":"proxy.go","path":"proxy.go","contentType":"file"},{"name":"proxy_test.go","path":"proxy_test.go","contentType":"file"},{"name":"responses.go","path":"responses.go","contentType":"file"},{"name":"signer.go","path":"signer.go","contentType":"file"},{"name":"signer_test.go","path":"signer_test.go","contentType":"file"}],"totalCount":26}},"fileTreeProcessingTime":2.445274,"foldersToFetch":[],"incompleteFileTree":false,"repo":{"id":126026015,"defaultBranch":"master","name":"goproxy","ownerLogin":"rbarbaresco","currentUserCanPush":false,"isFork":true,"isEmpty":false,"createdAt":"2018-03-20T13:59:16.000Z","ownerAvatar":"https://avatars.githubusercontent.com/u/881229?v=4","public":true,"private":false,"isOrgOwned":false},"codeLineWrapEnabled":false,"symbolsExpanded":false,"treeExpanded":true,"refInfo":{"name":"master","listCacheKey":"v0:1616519966.6481411","canEdit":false,"refType":"branch","currentOid":"a96fa3a318260eab29abaf32f7128c9eb07fb073"},"path":"signer.go","currentUser":null,"blob":{"rawLines":["package goproxy","","import (","\t\"crypto/rsa\"","\t\"crypto/sha1\"","\t\"crypto/tls\"","\t\"crypto/x509\"","\t\"crypto/x509/pkix\"","\t\"math/big\"","\t\"net\"","\t\"runtime\"","\t\"sort\"","\t\"time\"",")","","func hashSorted(lst []string) []byte {","\tc := make([]string, len(lst))","\tcopy(c, lst)","\tsort.Strings(c)","\th := sha1.New()","\tfor _, s := range c {","\t\th.Write([]byte(s + \",\"))","\t}","\treturn h.Sum(nil)","}","","func hashSortedBigInt(lst []string) *big.Int {","\trv := new(big.Int)","\trv.SetBytes(hashSorted(lst))","\treturn rv","}","","var goproxySignerVersion = \":goroxy1\"","","func signHost(ca tls.Certificate, hosts []string) (cert tls.Certificate, err error) {","\tvar x509ca *x509.Certificate","","\t// Use the provided ca and not the global GoproxyCa for certificate generation.","\tif x509ca, err = x509.ParseCertificate(ca.Certificate[0]); err != nil {","\t\treturn","\t}","\tstart := time.Unix(0, 0)","\tend, err := time.Parse(\"2006-01-02\", \"2049-12-31\")","\tif err != nil {","\t\tpanic(err)","\t}","\thash := hashSorted(append(hosts, goproxySignerVersion, \":\"+runtime.Version()))","\tserial := new(big.Int)","\tserial.SetBytes(hash)","\ttemplate := x509.Certificate{","\t\t// TODO(elazar): instead of this ugly hack, just encode the certificate and hash the binary form.","\t\tSerialNumber: serial,","\t\tIssuer: x509ca.Subject,","\t\tSubject: pkix.Name{","\t\t\tOrganization: []string{\"GoProxy untrusted MITM proxy Inc\"},","\t\t},","\t\tNotBefore: start,","\t\tNotAfter: end,","","\t\tKeyUsage: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature,","\t\tExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth},","\t\tBasicConstraintsValid: true,","\t}","\tfor _, h := range hosts {","\t\tif ip := net.ParseIP(h); ip != nil {","\t\t\ttemplate.IPAddresses = append(template.IPAddresses, ip)","\t\t} else {","\t\t\ttemplate.DNSNames = append(template.DNSNames, h)","\t\t}","\t}","\tvar csprng CounterEncryptorRand","\tif csprng, err = NewCounterEncryptorRandFromKey(ca.PrivateKey, hash); err != nil {","\t\treturn","\t}","\tvar certpriv *rsa.PrivateKey","\tif certpriv, err = rsa.GenerateKey(\u0026csprng, 1024); err != nil {","\t\treturn","\t}","\tvar derBytes []byte","\tif derBytes, err = x509.CreateCertificate(\u0026csprng, \u0026template, x509ca, \u0026certpriv.PublicKey, ca.PrivateKey); err != nil {","\t\treturn","\t}","\treturn tls.Certificate{","\t\tCertificate: [][]byte{derBytes, ca.Certificate[0]},","\t\tPrivateKey: certpriv,","\t}, nil","}"],"stylingDirectives":null,"colorizedLines":null,"csv":null,"csvError":null,"dependabotInfo":{"showConfigurationBanner":false,"configFilePath":null,"networkDependabotPath":"/rbarbaresco/goproxy/network/updates","dismissConfigurationNoticePath":"/settings/dismiss-notice/dependabot_configuration_notice","configurationNoticeDismissed":null},"displayName":"signer.go","displayUrl":"https://github.com/rbarbaresco/goproxy/blob/master/signer.go?raw=true","headerInfo":{"blobSize":"2.17 KB","deleteTooltip":"You must be signed in to make or propose changes","editTooltip":"You must be signed in to make or propose changes","ghDesktopPath":"https://desktop.github.com","isGitLfs":false,"onBranch":true,"shortPath":"f6d99fc","siteNavLoginPath":"/login?return_to=https%3A%2F%2Fgithub.com%2Frbarbaresco%2Fgoproxy%2Fblob%2Fmaster%2Fsigner.go","isCSV":false,"isRichtext":false,"toc":null,"lineInfo":{"truncatedLoc":"87","truncatedSloc":"80"},"mode":"file"},"image":false,"isCodeownersFile":null,"isPlain":false,"isValidLegacyIssueTemplate":false,"issueTemplate":null,"discussionTemplate":null,"language":"Go","languageID":132,"large":false,"planSupportInfo":{"repoIsFork":null,"repoOwnedByCurrentUser":null,"requestFullPath":"/rbarbaresco/goproxy/blob/master/signer.go","showFreeOrgGatedFeatureMessage":null,"showPlanSupportBanner":null,"upgradeDataAttributes":null,"upgradePath":null},"publishBannersInfo":{"dismissActionNoticePath":"/settings/dismiss-notice/publish_action_from_dockerfile","releasePath":"/rbarbaresco/goproxy/releases/new?marketplace=true","showPublishActionBanner":false},"rawBlobUrl":"https://github.com/rbarbaresco/goproxy/raw/refs/heads/master/signer.go","renderImageOrRaw":false,"richText":null,"renderedFileInfo":null,"shortPath":null,"symbolsEnabled":true,"tabSize":8,"topBannersInfo":{"overridingGlobalFundingFile":false,"globalPreferredFundingPath":null,"showInvalidCitationWarning":false,"citationHelpUrl":"https://docs.github.com/github/creating-cloning-and-archiving-repositories/creating-a-repository-on-github/about-citation-files","actionsOnboardingTip":null},"truncated":false,"viewable":true,"workflowRedirectUrl":null,"symbols":null},"copilotInfo":null,"copilotAccessAllowed":false,"modelsAccessAllowed":false,"modelsRepoIntegrationEnabled":false,"csrf_tokens":{"/rbarbaresco/goproxy/branches":{"post":"7vjppPYOomgNQBtE1k99wOcHiV59s1qNMlDRr295fqBnaxFiUA9a53KnqwFYPxXoRO_n9Vj82S1ivR4QaiTNEA"},"/repos/preferences":{"post":"_J4BLC-SSLOCsPvW2dDKNyrLqwiUvelvECAVAmdeB9Npw0iiHfAULQuwUanGB01xjP4umESA0CdsdnflU5ShlA"}}},"title":"goproxy/signer.go at master · rbarbaresco/goproxy","appPayload":{"helpUrl":"https://docs.github.com","findFileWorkerPath":"/assets-cdn/worker/find-file-worker-263cab1760dd.js","findInFileWorkerPath":"/assets-cdn/worker/find-in-file-worker-1b17b3e7786a.js","githubDevUrl":null,"enabled_features":{"code_nav_ui_events":false,"react_blob_overlay":false,"accessible_code_button":true}}}
0