Humanoid robots are being designed to perform tasks currently carried out by human workers in industry, manufacturing, service, and disaster assistance. To this end, the humanoid robot should be able to walk stably across many types of terrain. However, when traversing a complex unknown environment, it is difficult to realize accurate terrain perception immediately through large data collected by the sensor system, leading to a difference between planned foot landing positions and actual foot landing positions. As a result, an unexpected contact force/torque may affect the stability of the robot. This paper adopts active contact perception instead of terrain perception and proposes a contact force/torque control method based on the viscoelastic model to address this problem. In addition, we design a body stability controller based on tracking the trajectories of the virtual repellent point (VRP) and the divergent component of motion (DCM) to restrain the disturbance caused by the unexpected contact force/torque. Simulations and experiments on the BHR-6P humanoid robot platform demonstrate the proposed contact force/torque control method for walking on indefinite uneven terrain. Note to Practitioners —This paper presents a contact force/torque controller based on a viscoelastic model, which unifies contact perception and adaptive reaction. Using the viscoelastic model, we get the relationship between the end position/posture and the first-order differential of the contact force/torque, from which a state equation can be established and used to design a state feedback controller. Combining with body stabilization, we adopt this controller to modify the trajectory of both landing and support feet simultaneously for humanoid robots to realize stable bipedal walking on indefinite uneven terrain, which is validated in both simulations and experiments on the BHR-6P humanoid robot. In addition, this method can be employed for other robots or equipment when the contact force/torque control is needed; e.g., industry manipulators and quadruped robots.