| 981 | } |
| 982 | |
| 983 | static const char *md_config_set_pkeys(cmd_parms *cmd, void *dc, |
| 984 | int argc, char *const argv[]) |
| 985 | { |
| 986 | md_srv_conf_t *config = md_config_get(cmd->server); |
| 987 | const char *err, *ptype; |
| 988 | apr_int64_t bits; |
| 989 | int i; |
| 990 | |
| 991 | (void)dc; |
| 992 | if ((err = md_conf_check_location(cmd, MD_LOC_ALL))) { |
| 993 | return err; |
| 994 | } |
| 995 | if (argc <= 0) { |
| 996 | return "needs to specify the private key type"; |
| 997 | } |
| 998 | |
| 999 | config->pks = md_pkeys_spec_make(cmd->pool); |
| 1000 | for (i = 0; i < argc; ++i) { |
| 1001 | ptype = argv[i]; |
| 1002 | if (!apr_cstr_casecmp("Default", ptype)) { |
| 1003 | if (argc > 1) { |
| 1004 | return "'Default' allows no other parameter"; |
| 1005 | } |
| 1006 | md_pkeys_spec_add_default(config->pks); |
| 1007 | } |
| 1008 | else if (strlen(ptype) > 3 |
| 1009 | && (ptype[0] == 'R' || ptype[0] == 'r') |
| 1010 | && (ptype[1] == 'S' || ptype[1] == 's') |
| 1011 | && (ptype[2] == 'A' || ptype[2] == 'a') |
| 1012 | && isdigit(ptype[3])) { |
| 1013 | bits = (int)apr_atoi64(ptype+3); |
| 1014 | if (bits < MD_PKEY_RSA_BITS_MIN) { |
| 1015 | return apr_psprintf(cmd->pool, |
| 1016 | "must be %d or higher in order to be considered safe.", |
| 1017 | MD_PKEY_RSA_BITS_MIN); |
| 1018 | } |
| 1019 | if (bits >= INT_MAX) { |
| 1020 | return apr_psprintf(cmd->pool, "is too large for an RSA key length."); |
| 1021 | } |
| 1022 | if (md_pkeys_spec_contains_rsa(config->pks)) { |
| 1023 | return "two keys of type 'RSA' are not possible."; |
| 1024 | } |
| 1025 | md_pkeys_spec_add_rsa(config->pks, (unsigned int)bits); |
| 1026 | } |
| 1027 | else if (!apr_cstr_casecmp("RSA", ptype)) { |
| 1028 | if (i+1 >= argc || !isdigit(argv[i+1][0])) { |
| 1029 | bits = MD_PKEY_RSA_BITS_DEF; |
| 1030 | } |
| 1031 | else { |
| 1032 | ++i; |
| 1033 | bits = (int)apr_atoi64(argv[i]); |
| 1034 | if (bits < MD_PKEY_RSA_BITS_MIN) { |
| 1035 | return apr_psprintf(cmd->pool, |
| 1036 | "must be %d or higher in order to be considered safe.", |
| 1037 | MD_PKEY_RSA_BITS_MIN); |
| 1038 | } |
| 1039 | if (bits >= INT_MAX) { |
| 1040 | return apr_psprintf(cmd->pool, "is too large for an RSA key length."); |
nothing calls this directly
no test coverage detected