| 809 | /* DNS name checks ********************************************************************************/ |
| 810 | |
| 811 | int md_dns_is_name(apr_pool_t *p, const char *hostname, int need_fqdn) |
| 812 | { |
| 813 | char c, last = 0; |
| 814 | const char *cp = hostname; |
| 815 | int dots = 0; |
| 816 | |
| 817 | /* Since we use the names in certificates, we need pure ASCII domain names |
| 818 | * and IDN need to be converted to unicode. */ |
| 819 | while ((c = *cp++)) { |
| 820 | switch (c) { |
| 821 | case '.': |
| 822 | if (last == '.') { |
| 823 | md_log_perror(MD_LOG_MARK, MD_LOG_TRACE3, 0, p, "dns name with ..: %s", |
| 824 | hostname); |
| 825 | return 0; |
| 826 | } |
| 827 | ++dots; |
| 828 | break; |
| 829 | case '-': |
| 830 | break; |
| 831 | default: |
| 832 | if (!apr_isalnum(c)) { |
| 833 | md_log_perror(MD_LOG_MARK, MD_LOG_TRACE3, 0, p, "dns invalid char %c: %s", |
| 834 | c, hostname); |
| 835 | return 0; |
| 836 | } |
| 837 | break; |
| 838 | } |
| 839 | last = c; |
| 840 | } |
| 841 | |
| 842 | if (last == '.') { /* DNS names may end with '.' */ |
| 843 | --dots; |
| 844 | } |
| 845 | if (need_fqdn && dots <= 0) { /* do not accept just top level domains */ |
| 846 | md_log_perror(MD_LOG_MARK, MD_LOG_TRACE3, 0, p, "not a FQDN: %s", hostname); |
| 847 | return 0; |
| 848 | } |
| 849 | return 1; /* empty string not allowed */ |
| 850 | } |
| 851 | |
| 852 | int md_dns_is_wildcard(apr_pool_t *p, const char *domain) |
| 853 | { |
no test coverage detected