(id string)
| 42 | } |
| 43 | |
| 44 | func loadProfile(id string) (*profile, error) { |
| 45 | p := newProfile(id) |
| 46 | isAccount, err := p.IsAccount() |
| 47 | if err != nil { |
| 48 | return nil, errors.WithMessage(err, "is account") |
| 49 | } |
| 50 | for _, file := range ProfilePaths { |
| 51 | if !isAccount && (file == ProfileAccountName || file == ProfileAccountPass) { |
| 52 | continue |
| 53 | } |
| 54 | if isAccount && file == ProfileProv { |
| 55 | continue |
| 56 | } |
| 57 | if _, err := p.Stat(file); err != nil { |
| 58 | return nil, errors.WithMessagef(err, "check required file %s", file) |
| 59 | } |
| 60 | } |
| 61 | pass, err := p.GetString(ProfileCertPass) |
| 62 | if err != nil { |
| 63 | return nil, errors.WithMessagef(err, "get %s", ProfileCertPass) |
| 64 | } |
| 65 | origCertFile, err := p.GetFile(ProfileCert) |
| 66 | if err != nil { |
| 67 | return nil, errors.WithMessagef(err, "get %s", ProfileCert) |
| 68 | } |
| 69 | defer origCertFile.Close() |
| 70 | origCertBytes, err := ioutil.ReadAll(origCertFile) |
| 71 | if err != nil { |
| 72 | return nil, errors.WithMessage(err, "read cert file") |
| 73 | } |
| 74 | fixedCert, teamId, err := processP12(origCertBytes, pass) |
| 75 | if err != nil { |
| 76 | return nil, errors.WithMessage(err, "validate certificate") |
| 77 | } |
| 78 | p.fixedCert = fixedCert |
| 79 | p.teamId = teamId |
| 80 | return p, nil |
| 81 | } |
| 82 | |
| 83 | type PublicKeyComparator interface { |
| 84 | Equal(x crypto.PublicKey) bool |
no test coverage detected