Beispiel #1
0
func getEmail(interactor interaction.Interactor) (string, error) {
	for {
		res, err := interactor.Prompt(&interaction.Challenge{
			Title:        "E. Mail Address Required",
			ResponseType: interaction.RTLineString,
			Prompt:       "E. mail address: ",
			Body:         `Please enter an e. mail address where you can be reached. Although entering an e. mail address is optional, it is highly recommended.`,
			UniqueID:     "acme-enter-email",
		})
		if err != nil {
			return "", err
		}

		if res.Value == "" {
			return "", nil
		}

		if res.Cancelled {
			return "-", nil
		}

		addr, err := mail.ParseAddress(res.Value)
		if err != nil {
			continue
		}

		return addr.Address, nil
	}
}
Beispiel #2
0
// Using the given client and interactor (or interaction.Auto if nil), register
// the client account if it does not already exist.
//
// The interactor is used to prompt for terms of service agreement, if
// agreement has not already been obtained. An e. mail address is prompted for.
func AssistedUpsertRegistration(cl *acmeapi.Client, interactor interaction.Interactor, ctx context.Context) error {
	interactor = defaultInteraction(interactor)

	email := ""

	for {
		err := cl.AgreeRegistration(ctx)
		if err != nil {
			if e, ok := err.(*acmeapi.AgreementError); ok {
				res, err := interactor.Prompt(&interaction.Challenge{
					Title:        "Terms of Service Agreement Required",
					YesLabel:     "I Agree",
					NoLabel:      "Cancel",
					ResponseType: interaction.RTYesNo,
					UniqueID:     "acme-agreement:" + e.URI,
					Prompt:       "Do you agree to the Terms of Service?",
					Body: fmt.Sprintf(`You must agree to the terms of service at the following URL to continue:

%s

Do you agree to the terms of service set out in the above document?`, e.URI),
				})
				if err != nil {
					return err
				}
				if !res.Cancelled {
					if email == "" {
						email, err = getEmail(interactor)
						if err != nil {
							return err
						}
						if email == "-" {
							return fmt.Errorf("e. mail input cancelled")
						}
					}

					if cl.AccountInfo.AgreementURIs == nil {
						cl.AccountInfo.AgreementURIs = map[string]struct{}{}
					}
					cl.AccountInfo.AgreementURIs[e.URI] = struct{}{}
					if email != "" {
						cl.AccountInfo.ContactURIs = []string{"mailto:" + email}
					}
					continue
				}
			}
		}

		return err
	}
}
Beispiel #3
0
// Start is a no-op for the DNS method.
func (s *dnsResponder) Start(interactor interaction.Interactor) error {
	if interactor == nil {
		return fmt.Errorf("interaction func not provided but required")
	}

	log.Debug("dns-01 interaction prompt")
	_, err := interactor.Prompt(&interaction.Challenge{
		Title: "Verification DNS Record", Body: fmt.Sprintf(`All other verification methods have failed. In order to complete the DNS verification method, you must place the verification DNS record at

  _acme-challenge IN TXT %#v

under the name to be verified before continuing.

However, you should consider that it is likely to be easier for you to investigate and rectify the reason that the HTTP and TLSSNI challenges did not work. You may wish to consider this notice a failure condition.`, s.dnsString),
	})
	if err != nil {
		return err
	}

	return nil
}
Beispiel #4
0
func getEmail(interactor interaction.Interactor) (string, error) {
	for {
		res, err := interactor.Prompt(&interaction.Challenge{
			Title:        "E. Mail Address Required",
			ResponseType: interaction.RTLineString,
			Prompt:       "E. mail address: ",
			Body:         `Please enter an e. mail address where you can be reached. Although entering an e. mail address is optional, it is highly recommended.`,
			UniqueID:     "acme-enter-email",
		})
		if err != nil {
			return "", err
		}

		if res.Value == "" {
			return "", nil
		}

		if res.Cancelled {
			return "-", nil
		}

		addr, err := mail.ParseAddress(res.Value)
		if err != nil {
			if res.Noninteractive {
				// If the e. mail address specified was invalid but we received it from
				// a noninteractive source, don't loop or we will loop forever. Instead
				// just act like one wasn't specified.
				return "", nil
			}

			continue
		}

		return addr.Address, nil
	}
}