Vehicle ad hoc networks (VANETs) enable fast interconnection between vehicles and roadside infrastructure to ensure stable and continuous network services for vehicles. Data sharing, as the primary service of MANET, not only ensures vehicles can access the required information but also supports vehicles in sharing the required information with other vehicles to provide a better travel experience for drivers and passengers. However, without an effective access control scheme to protect data security, the adversaries can collect data transmitted by other vehicles during data sharing and threaten VANET's security by sending fake data. In order to address the current data-sharing scheme for vehicles that collects information from the environment with low efficiency, high maintenance cost and ineffective access control schemes, a secure and effective data-sharing scheme is proposed in this paper by improving the ciphertext policy attribute-based encryption algorithm (CP-ABE). Performance analysis and simulation experiments show that the scheme can achieve secure and efficient data sharing and enhance the driving experience. When the number of attributes is 20, the computational overhead of our scheme in the encryption phase is 3.18% of the compared scheme, while the computational overhead in the decryption phase is 44% of the compared scheme.