RSA is catastrophically weak with 512 bit keys, and anything less than 2048 bits is insecure. A minimum key size should be enforced. Golang has proposed to require 1024 bits minimum:
golang/go#68762
however 2048 would be a good choice where backwards compatibility requirements are minimal